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
/
^(0414|0424|0412|0416|0426)[-][0-9]{7}$
/
g
^ asserts position at start of the string
1st Capturing Group
(0414|0424|0412|0416|0426)
1st Alternative
0414
0414
matches the characters 0414 literally (case sensitive)
2nd Alternative
0424
0424
matches the characters 0424 literally (case sensitive)
3rd Alternative
0412
0412
matches the characters 0412 literally (case sensitive)
4th Alternative
0416
0416
matches the characters 0416 literally (case sensitive)
5th Alternative
0426
0426
matches the characters 0426 literally (case sensitive)
Match a single character present in the list below
[-]
- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
This hyphen is treated literally, which might be confusing for others. Consider escaping it or placing at the start or end of the class!
Match a single character present in the list below
[0-9]
{7} matches the previous token exactly 7 times
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
$ asserts position at the end of the string
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.

Regular Expression
No Match

/
/
g

Test String

Substitution

Processing...