Reputation: 1547
I need a regex that matches only 10, 11 and 12 numbers. I tried this:
\b[10|11|12]{1}\b
But no matches found here. Could you help me out?
Upvotes: 3
Views: 95
Reputation: 33827
You should use
\b(10|11|12)\b
Check it at work here
Also, no need to specify {1}
, it is implicit.
Square brackets are used to match a character from a set
Match anything inside the square brackets for ONE character position once and only once, for example, [12] means match the target to 1 and if that does not match then match the target to 2 while [0123456789] means match to any character in the range 0 to 9.
Upvotes: 5