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
/
^(7503|7504|8000|900\d)\d{6}$
/
^ asserts position at start of the string
1st Capturing Group
(7503|7504|8000|900\d)
1st Alternative
7503
7503
matches the characters 7503 literally (case sensitive)
2nd Alternative
7504
7504
matches the characters 7504 literally (case sensitive)
3rd Alternative
8000
8000
matches the characters 8000 literally (case sensitive)
4th Alternative
900\d
900
matches the characters 900 literally (case sensitive)
\d matches a digit (equivalent to [0-9])
\d
matches a digit (equivalent to [0-9])
{6} matches the previous token exactly 6 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