Regular Expressions 101

Save & Share

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
"
(restaur*|bar|brasserie|\sbouches?\s)
"
gm
1st Capturing Group
(restaur*|bar|brasserie|\sbouches?\s)
1st Alternative
restaur*
restau
matches the characters restau literally (case sensitive)
r
matches the character r with index 11410 (7216 or 1628) literally (case sensitive)
2nd Alternative
bar
bar
matches the characters bar literally (case sensitive)
3rd Alternative
brasserie
brasserie
matches the characters brasserie literally (case sensitive)
4th Alternative
\sbouches?\s
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
bouche
matches the characters bouche literally (case sensitive)
s
matches the character s with index 11510 (7316 or 1638) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
matches the character with index 3210 (2016 or 408) literally (case sensitive)
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

r"
"
gm

Test String