Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>((\d{9})|(\d{11})$ </code></pre> <p>...is not a valid regular expression because it is missing a parenthesis.</p> <p>Here is the corrected regular expression which you probably intended to write in your question:</p> <pre><code>((\d{9})|(\d{11}))$ </code></pre> <p>Now, as to your question, you would like to limit the number of digits entered to only 9 or 11. Here's how to do that:</p> <pre><code>^((\d{9})|(\d{11}))$ </code></pre> <p>What we are doing is defining the start <code>^</code> and end <code>$</code> of the expression so that the regular expression engine knows how to parse the data.</p> <p>If you don't define a start and an end, the expression is "greedy" by default, which is why it was matching more than 9 or 11 digits. Since you only defined an end, it matched <em>all</em> occurrences of start, which is each combination of 9 or 11.</p> <p>As already pointed out, if you want to match characters, you'll need to substitute a different expression:</p> <pre><code>^((.{9})|(.{11}))$ </code></pre> <p>If you only want to match numbers, letters, and underscores, you could use this:</p> <pre><code>^(([A-Za-z_0-9]{9})|([A-Za-z_0-9]{11}))$ </code></pre> <p>However, in any case, the expression can be more easily defined as:</p> <pre><code>^.{9,11}$ </code></pre> <p>And you would substitute either <code>[A-Za-z_0-9]</code> or <code>\d</code> depending on your needs.</p> <p>The additional <code>()</code> you have around your original expression are not needed for a basic matching regular expression. They are required if you need capture groups for replacements.</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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    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