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
/
\/(|en-US|en-GB|en-AU|fr-CA|en-CA|es-MX|tr-TR)*\/*(legal-platform)\/+
/
gm
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
1st Capturing Group
(|en-US|en-GB|en-AU|fr-CA|en-CA|es-MX|tr-TR)*
* 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
1st Alternative null, matches any position
2nd Alternative
en-US
en-US
matches the characters en-US literally (case sensitive)
3rd Alternative
en-GB
en-GB
matches the characters en-GB literally (case sensitive)
4th Alternative
en-AU
en-AU
matches the characters en-AU literally (case sensitive)
5th Alternative
fr-CA
fr-CA
matches the characters fr-CA literally (case sensitive)
6th Alternative
en-CA
en-CA
matches the characters en-CA literally (case sensitive)
7th Alternative
es-MX
es-MX
matches the characters es-MX literally (case sensitive)
8th Alternative
tr-TR
tr-TR
matches the characters tr-TR literally (case sensitive)
\/
matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
2nd Capturing Group
(legal-platform)
legal-platform
matches the characters legal-platform literally (case sensitive)
\/
matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
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