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
/
([^@`]|\s+|^)((th(n[qx]|x)|t[xyq])|((than[kx])([sxz]){0,2})(u|y(ou)?|q)?)\b
/
gi
1st Capturing Group
([^@`]|\s+|^)
1st Alternative
[^@`]
Match a single character not present in the list below
[^@`]
@`
matches a single character in the list @` (case insensitive)
2nd Alternative
\s+
\s
matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
3rd Alternative
^
^ asserts position at start of the string
2nd Capturing Group
((th(n[qx]|x)|t[xyq])|((than[kx])([sxz]){0,2})(u|y(ou)?|q)?)
1st Alternative
(th(n[qx]|x)|t[xyq])
3rd Capturing Group
(th(n[qx]|x)|t[xyq])
1st Alternative
th(n[qx]|x)
th
matches the characters th literally (case insensitive)
4th Capturing Group
(n[qx]|x)
1st Alternative
n[qx]
n matches the character n with index 11010 (6E16 or 1568) literally (case insensitive)
Match a single character present in the list below
[qx]
qx
matches a single character in the list qx (case insensitive)
2nd Alternative
x
x matches the character x with index 12010 (7816 or 1708) literally (case insensitive)
2nd Alternative
t[xyq]
t matches the character t with index 11610 (7416 or 1648) literally (case insensitive)
Match a single character present in the list below
[xyq]
xyq
matches a single character in the list xyq (case insensitive)
2nd Alternative
((than[kx])([sxz]){0,2})(u|y(ou)?|q)?
5th Capturing Group
((than[kx])([sxz]){0,2})
6th Capturing Group
(than[kx])
than
matches the characters than literally (case insensitive)
Match a single character present in the list below
[kx]
kx
matches a single character in the list kx (case insensitive)
7th Capturing Group
([sxz]){0,2}
{0,2} matches the previous token between 0 and 2 times, as many times as possible, giving back as needed (greedy)
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
Match a single character present in the list below
[sxz]
sxz
matches a single character in the list sxz (case insensitive)
8th Capturing Group
(u|y(ou)?|q)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
u
u matches the character u with index 11710 (7516 or 1658) literally (case insensitive)
2nd Alternative
y(ou)?
y matches the character y with index 12110 (7916 or 1718) literally (case insensitive)
9th Capturing Group
(ou)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
ou
matches the characters ou literally (case insensitive)
3rd Alternative
q
q matches the character q with index 11310 (7116 or 1618) literally (case insensitive)
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
Global pattern flags
g modifier: global. All matches (don't return after first match)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Your regular expression does not match the subject string.

Regular Expression
No Match

/
/
gi

Test String