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
/
\b((bc|tb)(0([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})|1[ac-hj-np-z02-9]{8,87})|([13]|[mn2])[a-km-zA-HJ-NP-Z1-9]{25,39})\b\s
/
gm
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
1st Capturing Group
((bc|tb)(0([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})|1[ac-hj-np-z02-9]{8,87})|([13]|[mn2])[a-km-zA-HJ-NP-Z1-9]{25,39})
1st Alternative
(bc|tb)(0([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})|1[ac-hj-np-z02-9]{8,87})
2nd Capturing Group
(bc|tb)
1st Alternative
bc
bc
matches the characters bc literally (case sensitive)
2nd Alternative
tb
tb
matches the characters tb literally (case sensitive)
3rd Capturing Group
(0([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})|1[ac-hj-np-z02-9]{8,87})
1st Alternative
0([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
4th Capturing Group
([ac-hj-np-z02-9]{39}|[ac-hj-np-z02-9]{59})
1st Alternative
[ac-hj-np-z02-9]{39}
Match a single character present in the list below
[ac-hj-np-z02-9]
{39} matches the previous token exactly 39 times
a matches the character a with index 9710 (6116 or 1418) literally (case sensitive)
c-h matches a single character in the range between c (index 99) and h (index 104) (case sensitive)
j-n matches a single character in the range between j (index 106) and n (index 110) (case sensitive)
p-z matches a single character in the range between p (index 112) and z (index 122) (case sensitive)
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
2-9 matches a single character in the range between 2 (index 50) and 9 (index 57) (case sensitive)
2nd Alternative
[ac-hj-np-z02-9]{59}
Match a single character present in the list below
[ac-hj-np-z02-9]
{59} matches the previous token exactly 59 times
a matches the character a with index 9710 (6116 or 1418) literally (case sensitive)
c-h matches a single character in the range between c (index 99) and h (index 104) (case sensitive)
j-n matches a single character in the range between j (index 106) and n (index 110) (case sensitive)
p-z matches a single character in the range between p (index 112) and z (index 122) (case sensitive)
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
2-9 matches a single character in the range between 2 (index 50) and 9 (index 57) (case sensitive)
2nd Alternative
1[ac-hj-np-z02-9]{8,87}
1 matches the character 1 with index 4910 (3116 or 618) literally (case sensitive)
Match a single character present in the list below
[ac-hj-np-z02-9]
{8,87} matches the previous token between 8 and 87 times, as many times as possible, giving back as needed (greedy)
a matches the character a with index 9710 (6116 or 1418) literally (case sensitive)
c-h matches a single character in the range between c (index 99) and h (index 104) (case sensitive)
j-n matches a single character in the range between j (index 106) and n (index 110) (case sensitive)
p-z matches a single character in the range between p (index 112) and z (index 122) (case sensitive)
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
2-9 matches a single character in the range between 2 (index 50) and 9 (index 57) (case sensitive)
2nd Alternative
([13]|[mn2])[a-km-zA-HJ-NP-Z1-9]{25,39}
5th Capturing Group
([13]|[mn2])
1st Alternative
[13]
Match a single character present in the list below
[13]
13
matches a single character in the list 13 (case sensitive)
2nd Alternative
[mn2]
Match a single character present in the list below
[mn2]
mn2
matches a single character in the list mn2 (case sensitive)
Match a single character present in the list below
[a-km-zA-HJ-NP-Z1-9]
{25,39} matches the previous token between 25 and 39 times, as many times as possible, giving back as needed (greedy)
a-k matches a single character in the range between a (index 97) and k (index 107) (case sensitive)
m-z matches a single character in the range between m (index 109) and z (index 122) (case sensitive)
A-H matches a single character in the range between A (index 65) and H (index 72) (case sensitive)
J-N matches a single character in the range between J (index 74) and N (index 78) (case sensitive)
P-Z matches a single character in the range between P (index 80) and Z (index 90) (case sensitive)
1-9 matches a single character in the range between 1 (index 49) and 9 (index 57) (case sensitive)
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
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.

Regular Expression
No Match

/
/
gm

Test String