Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Have a try with:</p> <pre><code>/^(C\d{4}[a-zA-Z]\d{7}|[a-zA-Z]{2}\d{6}[a-zA-Z]?|\d{9})$/ </code></pre> <p>I suppose that the last alpha is optional in the rule #2</p> <p><strong>explanation:</strong></p> <pre><code>The regular expression: (?-imsx:^(C\d{4}[a-zA-Z]\d{7}|[a-zA-Z]{2}\d{6}[a-zA-Z]?|\d{9})$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- C 'C' ---------------------------------------------------------------------- \d{4} digits (0-9) (4 times) ---------------------------------------------------------------------- [a-zA-Z] any character of: 'a' to 'z', 'A' to 'Z' ---------------------------------------------------------------------- \d{7} digits (0-9) (7 times) ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- [a-zA-Z]{2} any character of: 'a' to 'z', 'A' to 'Z' (2 times) ---------------------------------------------------------------------- \d{6} digits (0-9) (6 times) ---------------------------------------------------------------------- [a-zA-Z]? any character of: 'a' to 'z', 'A' to 'Z' (optional (matching the most amount possible)) ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- \d{9} digits (0-9) (9 times) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- </code></pre>
 

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