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
/
(red|blue|green) (colou?r|chroma)
/
gm
1st Capturing Group
(red|blue|green)
1st Alternative
red
red
matches the characters red literally (case sensitive)
2nd Alternative
blue
blue
matches the characters blue literally (case sensitive)
3rd Alternative
green
green
matches the characters green literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
2nd Capturing Group
(colou?r|chroma)
1st Alternative
colou?r
colo
matches the characters colo literally (case sensitive)
u
matches the character u with index 11710 (7516 or 1658) literally (case sensitive)
r matches the character r with index 11410 (7216 or 1628) literally (case sensitive)
2nd Alternative
chroma
chroma
matches the characters chroma literally (case sensitive)
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

Substitution

Processing...