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\+1-.{3}-.{3}-.{4}\b
/
gm
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
\+ matches the character + with index 4310 (2B16 or 538) literally (case sensitive)
1-
matches the characters 1- literally (case sensitive)
.
matches any character (except for line terminators)
{3} matches the previous token exactly 3 times
- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
.
matches any character (except for line terminators)
{3} matches the previous token exactly 3 times
- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
.
matches any character (except for line terminators)
{4} matches the previous token exactly 4 times
\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)
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.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String