Regular Expressions 101

Save & Share

  • Save Regex
  • Update Regex


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


  • Match
  • Substitution
  • List
  • Unit Tests
(\W|\s|\d|\w|\S)([7, 8][0-9]{10})
1st Capturing Group
1st Alternative
\W matches any non-word character (equivalent to [^a-zA-Z0-9_])
2nd Alternative
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
3rd Alternative
\d matches a digit (equivalent to [0-9])
4th Alternative
\w matches any word character (equivalent to [a-zA-Z0-9_])
5th Alternative
\S matches any non-whitespace character (equivalent to [^\r\n\t\f\v ])
2nd Capturing Group
([7, 8][0-9]{10})
Match a single character present in the list below
[7, 8]
7, 8
matches a single character in the list 7, 8 (case sensitive)
Match a single character present in the list below
{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)
Global pattern flags
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match


Test String



Code Generator

Generated Code

Loading code sample...
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report.
For a full regex reference for PHP, please visit: