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
/
\+[7] \([^8]\d\d\) \d{3} - \d{2} - \d{2}$
/
\+ matches the character + with index 4310 (2B16 or 538) literally (case sensitive)
Match a single character present in the list below
[7]
7 matches the character 7 with index 5510 (3716 or 678) literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
Match a single character not present in the list below
[^8]
8 matches the character 8 with index 5610 (3816 or 708) literally (case sensitive)
\d matches a digit (equivalent to [0-9])
\d matches a digit (equivalent to [0-9])
\) matches the character ) with index 4110 (2916 or 518) literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
{3} matches the previous token exactly 3 times
-
matches the characters - literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
{2} matches the previous token exactly 2 times
-
matches the characters - literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
{2} matches the previous token exactly 2 times
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/

Test String