Regular Expressions 101

Save & Share

  • Save 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(_?)foo\1\b
/
g
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
1st Capturing Group
(_?)
_
matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
foo
matches the characters foo literally (case sensitive)
\1 matches the same text as most recently matched by the 1st capturing group
\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)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
g

Test String