# Regular Expressions 101

## Flavor

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

• Match
• Substitution
• List
• Unit Tests

## Tools

/
^\d-(((0[13578]|1[02])-(0[1-9]|[12]\d|3[0-1]))|(02-(0[1-9]|[12]\d))|((0[469]|11)-(0[1-9]|[12]\d|30)))\$
/
gm
^ asserts position at start of a line
\d
matches a digit (equivalent to [0-9])
{4} matches the previous token exactly 4 times
- matches the character - literally (case sensitive)
1st Capturing Group
(((0[13578]|1[02])-(0[1-9]|[12]\d|3[0-1]))|(02-(0[1-9]|[12]\d))|((0[469]|11)-(0[1-9]|[12]\d|30)))
1st Alternative
((0[13578]|1[02])-(0[1-9]|[12]\d|3[0-1]))
2nd Capturing Group
((0[13578]|1[02])-(0[1-9]|[12]\d|3[0-1]))
3rd Capturing Group
(0[13578]|1[02])
1st Alternative
0[13578]
0 matches the character 0 literally (case sensitive)
Match a single character present in the list below
[13578]
2nd Alternative
1[02]
- matches the character - literally (case sensitive)
4th Capturing Group
(0[1-9]|[12]\d|3[0-1])
2nd Alternative
(02-(0[1-9]|[12]\d))
5th Capturing Group
(02-(0[1-9]|[12]\d))
02- matches the characters 02- literally (case sensitive)
6th Capturing Group
(0[1-9]|[12]\d)
3rd Alternative
((0[469]|11)-(0[1-9]|[12]\d|30))
7th Capturing Group
((0[469]|11)-(0[1-9]|[12]\d|30))
8th Capturing Group
(0[469]|11)
- matches the character - literally (case sensitive)
9th Capturing Group
(0[1-9]|[12]\d|30)
\$ asserts position at the end of a line
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.

/
/
gm