# Regular Expressions 101

## Flavor

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

• Match
• Substitution
• List
• Unit Tests

## Tools

/
^([^\|]{1,20})\|([^\|]{3,50})\|(([\d]{4}){4})\|((0[1-9]|1[0-2])(0[1-9]|[1-9][0-9]))\$
/
^ asserts position at start of the string
1st Capturing Group
([^\|]{1,20})
Match a single character not present in the list below
[^\|]
{1,20} matches the previous token between 1 and 20 times, as many times as possible, giving back as needed (greedy)
\| matches the character | with index 12410 (7C16 or 1748) literally (case sensitive)
\| matches the character | with index 12410 (7C16 or 1748) literally (case sensitive)
2nd Capturing Group
([^\|]{3,50})
Match a single character not present in the list below
[^\|]
{3,50} matches the previous token between 3 and 50 times, as many times as possible, giving back as needed (greedy)
\| matches the character | with index 12410 (7C16 or 1748) literally (case sensitive)
\| matches the character | with index 12410 (7C16 or 1748) literally (case sensitive)
3rd Capturing Group
(([\d]{4}){4})
4th Capturing Group
([\d]{4}){4}
{4} matches the previous token exactly 4 times
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
Match a single character present in the list below
[\d]
{4} matches the previous token exactly 4 times
\d matches a digit (equivalent to [0-9])
\| matches the character | with index 12410 (7C16 or 1748) literally (case sensitive)
5th Capturing Group
((0[1-9]|1[0-2])(0[1-9]|[1-9][0-9]))
6th Capturing Group
(0[1-9]|1[0-2])
1st Alternative
0[1-9]
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
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)
2nd Alternative
1[0-2]
1 matches the character 1 with index 4910 (3116 or 618) literally (case sensitive)
Match a single character present in the list below
[0-2]
0-2 matches a single character in the range between 0 (index 48) and 2 (index 50) (case sensitive)
7th Capturing Group
(0[1-9]|[1-9][0-9])
1st Alternative
0[1-9]
0 matches the character 0 with index 4810 (3016 or 608) literally (case sensitive)
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)
2nd Alternative
[1-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
[0-9]
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, 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.

/
/