Regular Expressions 101

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
^(3[47][0-9]{13}|(6541|6556)[0-9]{12}|389[0-9]{11}|3(?:0[0-5]|[68][0-9])[0-9]{11}|65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})|63[7-9][0-9]{13}|(?:2131|1800|35\d{3})\d{11}|9[0-9]{15}|(6304|6706|6709|6771)[0-9]{12,15}|(5018|5020|5038|6304|6759|6761|6763)[0-9]{8,15}|(5[1-5][0-9]{14}|2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12}))|(6334|6767)[0-9]{12}|(6334|6767)[0-9]{14}|(6334|6767)[0-9]{15}|(4903|4905|4911|4936|6333|6759)[0-9]{12}|(4903|4905|4911|4936|6333|6759)[0-9]{14}|(4903|4905|4911|4936|6333|6759)[0-9]{15}|564182[0-9]{10}|564182[0-9]{12}|564182[0-9]{13}|633110[0-9]{10}|633110[0-9]{12}|633110[0-9]{13}|(62[0-9]{14,17})|4[0-9]{12}(?:[0-9]{3})?|(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}))$
/
gm
^ asserts position at start of a line
1st Capturing Group
(3[47][0-9]{13}|(6541|6556)[0-9]{12}|389[0-9]{11}|3(?:0[0-5]|[68][0-9])[0-9]{11}|65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})|63[7-9][0-9]{13}|(?:2131|1800|35\d{3})\d{11}|9[0-9]{15}|(6304|6706|6709|6771)[0-9]{12,15}|(5018|5020|5038|6304|6759|6761|6763)[0-9]{8,15}|(5[1-5][0-9]{14}|2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12}))|(6334|6767)[0-9]{12}|(6334|6767)[0-9]{14}|(6334|6767)[0-9]{15}|(4903|4905|4911|4936|6333|6759)[0-9]{12}|(4903|4905|4911|4936|6333|6759)[0-9]{14}|(4903|4905|4911|4936|6333|6759)[0-9]{15}|564182[0-9]{10}|564182[0-9]{12}|564182[0-9]{13}|633110[0-9]{10}|633110[0-9]{12}|633110[0-9]{13}|(62[0-9]{14,17})|4[0-9]{12}(?:[0-9]{3})?|(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}))
1st Alternative
3[47][0-9]{13}
3 matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
Match a single character present in the list below
[47]
47
matches a single character in the list 47 (case sensitive)
Match a single character present in the list below
[0-9]
{13} matches the previous token exactly 13 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
2nd Alternative
(6541|6556)[0-9]{12}
2nd Capturing Group
(6541|6556)
1st Alternative
6541
6541
matches the characters 6541 literally (case sensitive)
2nd Alternative
6556
6556
matches the characters 6556 literally (case sensitive)
Match a single character present in the list below
[0-9]
{12} matches the previous token exactly 12 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
3rd Alternative
389[0-9]{11}
389
matches the characters 389 literally (case sensitive)
Match a single character present in the list below
[0-9]
{11} matches the previous token exactly 11 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
4th Alternative
3(?:0[0-5]|[68][0-9])[0-9]{11}
3 matches the character 3 with index 5110 (3316 or 638) literally (case sensitive)
Non-capturing group
(?:0[0-5]|[68][0-9])
1st Alternative
0[0-5]
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
Match a single character present in the list below
[0-5]
0-5 matches a single character in the range between 0 (index 48) and 5 (index 53) (case sensitive)
2nd Alternative
[68][0-9]
Match a single character present in the list below
[68]
68
matches a single character in the list 68 (case sensitive)
Match a single character present in the list below
[0-9]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
Match a single character present in the list below
[0-9]
{11} matches the previous token exactly 11 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
5th Alternative
65[4-9][0-9]{13}
65
matches the characters 65 literally (case sensitive)
Match a single character present in the list below
[4-9]
4-9 matches a single character in the range between 4 (index 52) and 9 (index 57) (case sensitive)
Match a single character present in the list below
[0-9]
{13} matches the previous token exactly 13 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
6th Alternative
64[4-9][0-9]{13}
64
matches the characters 64 literally (case sensitive)
Match a single character present in the list below
[4-9]
4-9 matches a single character in the range between 4 (index 52) and 9 (index 57) (case sensitive)
Match a single character present in the list below
[0-9]
{13} matches the previous token exactly 13 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
7th Alternative
6011[0-9]{12}
6011
matches the characters 6011 literally (case sensitive)
Match a single character present in the list below
[0-9]
{12} matches the previous token exactly 12 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
8th Alternative
(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})
3rd Capturing Group
(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})
622
matches the characters 622 literally (case sensitive)
Non-capturing group
(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])
1st Alternative
12[6-9]
12
matches the characters 12 literally (case sensitive)
Match a single character present in the list below
[6-9]
6-9 matches a single character in the range between 6 (index 54) and 9 (index 57) (case sensitive)
2nd Alternative
1[3-9][0-9]
1 matches the character 1 with index 4910 (3116 or 618) literally (case sensitive)
Match a single character present in the list below
[3-9]
3-9 matches a single character in the range between 3 (index 51) and 9 (index 57) (case sensitive)
Match a single character present in the list below
[0-9]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
3rd Alternative
[2-8][0-9][0-9]
Match a single character present in the list below
[2-8]
2-8 matches a single character in the range between 2 (index 50) and 8 (index 56) (case sensitive)
Match a single character present in the list below
[0-9]
Match a single character present in the list below
[0-9]
4th Alternative
9[01][0-9]
5th Alternative
92[0-5]
Match a single character present in the list below
[0-9]
{10} matches the previous token exactly 10 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
9th Alternative
63[7-9][0-9]{13}
63
matches the characters 63 literally (case sensitive)
Match a single character present in the list below
[7-9]
7-9 matches a single character in the range between 7 (index 55) and 9 (index 57) (case sensitive)
Match a single character present in the list below
[0-9]
{13} matches the previous token exactly 13 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
10th Alternative
(?:2131|1800|35\d{3})\d{11}
Non-capturing group
(?:2131|1800|35\d{3})
1st Alternative
2131
2131
matches the characters 2131 literally (case sensitive)
2nd Alternative
1800
1800
matches the characters 1800 literally (case sensitive)
3rd Alternative
35\d{3}
\d
matches a digit (equivalent to [0-9])
{11} matches the previous token exactly 11 times
11th Alternative
9[0-9]{15}
9 matches the character 9 with index 5710 (3916 or 718) literally (case sensitive)
Match a single character present in the list below
[0-9]
{15} matches the previous token exactly 15 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
12th Alternative
(6304|6706|6709|6771)[0-9]{12,15}
13th Alternative
(5018|5020|5038|6304|6759|6761|6763)[0-9]{8,15}
14th Alternative
(5[1-5][0-9]{14}|2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12}))
15th Alternative
(6334|6767)[0-9]{12}
16th Alternative
(6334|6767)[0-9]{14}
17th Alternative
(6334|6767)[0-9]{15}
18th Alternative
(4903|4905|4911|4936|6333|6759)[0-9]{12}
19th Alternative
(4903|4905|4911|4936|6333|6759)[0-9]{14}
20th Alternative
(4903|4905|4911|4936|6333|6759)[0-9]{15}
21st Alternative
564182[0-9]{10}
22nd Alternative
564182[0-9]{12}
23rd Alternative
564182[0-9]{13}
24th Alternative
633110[0-9]{10}
25th Alternative
633110[0-9]{12}
26th Alternative
633110[0-9]{13}
27th Alternative
(62[0-9]{14,17})
28th Alternative
4[0-9]{12}(?:[0-9]{3})?
29th Alternative
(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14})
$ asserts position at the end of a line
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String