Regular Expressions 101

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
^([1-9][9][0-9][0-9]|[2-9]\d{3})
/
gm
^ asserts position at start of a line
1st Capturing Group
([1-9][9][0-9][0-9]|[2-9]\d{3})
1st Alternative
[1-9][9][0-9][0-9]
Match a single character present in the list below
[1-9]
1-9 matches a single character in the range between 1 (index 49) and 9 (index 57) (case sensitive)
Match a single character present in the list below
[9]
9 matches the character 9 with index 5710 (3916 or 718) literally (case sensitive)
Match a single character present in the list below
[0-9]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
Match a single character present in the list below
[0-9]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
2nd Alternative
[2-9]\d{3}
Match a single character present in the list below
[2-9]
2-9 matches a single character in the range between 2 (index 50) and 9 (index 57) (case sensitive)
\d
matches a digit (equivalent to [0-9])
{3} matches the previous token exactly 3 times
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