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
/
\bfoo\b|\b_foo_\b
/
g
1st Alternative
\bfoo\b
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
foo
matches the characters foo literally (case sensitive)
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
2nd Alternative
\b_foo_\b
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
_foo_
matches the characters _foo_ literally (case sensitive)
\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