Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you mean just the syntax then this regexp should work for you</p> <pre><code>import re ... if re.match("[0-9a-f]{2}([-:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", x.lower()): ... </code></pre> <p>it accepts 12 hex digits with either <code>:</code> or <code>-</code> or nothing as separators between pairs (but the separator must be uniform... either all separators are <code>:</code> or are all <code>-</code> or there is no separator).</p> <p>This is the explanation:</p> <ul> <li><code>[0-9a-f]</code> means an hexadecimal digit</li> <li><code>{2}</code> means that we want two of them</li> <li><code>[-:]?</code> means either a dash or a colon but optional. Note that the dash as <strong>first</strong> char doesn't mean a range but only means itself. This subexpression is enclosed in parenthesis so it can be reused later as a back reference.</li> <li><code>[0-9a-f]{2}</code> is another pair of hexadecimal digits</li> <li><code>\\1</code> this means that we want to match the same expression that we matched before as separator. This is what guarantees uniformity. Note that the regexp syntax is <code>\1</code> but I'm using a regular string so backslash must be escaped by doubling it.</li> <li><code>[0-9a-f]{2}</code> another pair of hex digits</li> <li><code>{4}</code> the previous parenthesized block must be repeated exactly 4 times, giving a total of 6 pairs of digits: <code>&lt;pair&gt; &lt;sep&gt; &lt;pair&gt; ( &lt;same-sep&gt; &lt;pair&gt; ) * 4</code></li> <li><code>$</code> The string must end right after them</li> </ul> <p>Note that in Python <code>re.match</code> only checks starting at the start of the string and therefore a <code>^</code> at the beginning is not needed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload