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
"
(b|t)[ea]r
"
gm
1st Capturing Group
(b|t)
1st Alternative
b
b matches the character b with index 9810 (6216 or 1428) literally (case sensitive)
2nd Alternative
t
t matches the character t with index 11610 (7416 or 1648) literally (case sensitive)
Match a single character present in the list below
[ea]
ea
matches a single character in the list ea (case sensitive)
r matches the character r with index 11410 (7216 or 1628) 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