Regular Expressions 101

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
([P.$?]\$|[]^]P|G\]\$|CG)$
/
mg
1st Capturing Group
([P.$?]\$|[]^]P|G\]\$|CG)
1st Alternative
[P.$?]\$
Match a single character present in the list below
[P.$?]
P.$?
matches a single character in the list P.$? (case sensitive)
\$ matches the character $ with index 3610 (2416 or 448) literally (case sensitive)
2nd Alternative
[]^]P
Match a single character present in the list below
[]^]
]^
matches a single character in the list ]^ (case sensitive)
P matches the character P with index 8010 (5016 or 1208) literally (case sensitive)
3rd Alternative
G\]\$
G matches the character G with index 7110 (4716 or 1078) literally (case sensitive)
\] matches the character ] with index 9310 (5D16 or 1358) literally (case sensitive)
\$ matches the character $ with index 3610 (2416 or 448) literally (case sensitive)
4th Alternative
CG
CG
matches the characters CG literally (case sensitive)
$ asserts position at the end of a line
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.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
mg

Test String