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
"
(?P<master>([a-zA-Z0-9_]*\.|))Sequence\((\s*|)((!?(?P=master))([a-zA-Z0-9_]*)\(([a-zA-Z0-9_\(\)\,=>\{\}\s]*)\)(\,\s*|\,\n|\,|()))*(\n|)\)\;
"
mg
Named Capture Group master
(?P<master>([a-zA-Z0-9_]*\.|))
2nd Capturing Group
([a-zA-Z0-9_]*\.|)
1st Alternative
[a-zA-Z0-9_]*\.
Match a single character present in the list below
[a-zA-Z0-9_]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
_ matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
2nd Alternative null, matches any position
Sequence
matches the characters Sequence literally (case sensitive)
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
3rd Capturing Group
(\s*|)
1st Alternative
\s*
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
2nd Alternative null, matches any position
4th Capturing Group
((!?(?P=master))([a-zA-Z0-9_]*)\(([a-zA-Z0-9_\(\)\,=>\{\}\s]*)\)(\,\s*|\,\n|\,|()))*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
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
5th Capturing Group
(!?(?P=master))
!
matches the character ! with index 3310 (2116 or 418) literally (case sensitive)
(?P=master) matches the same text as most recently matched by the capturing group named master
6th Capturing Group
([a-zA-Z0-9_]*)
Match a single character present in the list below
[a-zA-Z0-9_]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
_ matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
7th Capturing Group
([a-zA-Z0-9_\(\)\,=>\{\}\s]*)
Match a single character present in the list below
[a-zA-Z0-9_\(\)\,=>\{\}\s]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
_ matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
\( matches the character ( with index 4010 (2816 or 508) literally (case sensitive)
\) matches the character ) with index 4110 (2916 or 518) literally (case sensitive)
\, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
=>
matches a single character in the list => (case sensitive)
\{ matches the character { with index 12310 (7B16 or 1738) literally (case sensitive)
\} matches the character } with index 12510 (7D16 or 1758) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
\) matches the character ) with index 4110 (2916 or 518) literally (case sensitive)
8th Capturing Group
(\,\s*|\,\n|\,|())
1st Alternative
\,\s*
\, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
2nd Alternative
\,\n
\, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
\n matches a line-feed (newline) character (ASCII 10)
3rd Alternative
\,
\, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
4th Alternative
()
9th Capturing Group
()
null, matches any position
10th Capturing Group
(\n|)
1st Alternative
\n
\n matches a line-feed (newline) character (ASCII 10)
2nd Alternative null, matches any position
\) matches the character ) with index 4110 (2916 or 518) literally (case sensitive)
\; matches the character ; with index 5910 (3B16 or 738) literally (case sensitive)
matches the character with index 1010 (A16 or 128) literally (case sensitive)
Global pattern flags
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
mg

Test String