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(?:\b|_)
/
g
Non-capturing group
(?:\b|_)
1st Alternative
\b
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
2nd Alternative
_
_ matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
foo
matches the characters foo literally (case sensitive)
Non-capturing group
(?:\b|_)
1st Alternative
\b
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
2nd Alternative
_
_ matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
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