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
"
[H\h]ello,? [W|w]orld!?
"
gm
Match a single character present in the list below
[H\h]
H matches the character H with index 7210 (4816 or 1108) literally (case sensitive)
\h matches the character h with index 10410 (6816 or 1508) literally (case sensitive)
ello
matches the characters ello literally (case sensitive)
,
matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
Match a single character present in the list below
[W|w]
W|w
matches a single character in the list W|w (case sensitive)
orld
matches the characters orld literally (case sensitive)
!
matches the character ! with index 3310 (2116 or 418) 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.

Regular Expression
No Match

r"
"
gm

Test String