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
/
( 's| 'd)|[[:lower:]](\.|\!|\?) ?"?[[:lower:]]|(\w|"),"?\w|( |^)"?(i|"|'|,|\!|\?|\.)(\s|")|_|(|)|\|
/
gm
1st Alternative
( 's| 'd)
1st Capturing Group
( 's| 'd)
1st Alternative
's
's
matches the characters 's literally (case sensitive)
2nd Alternative
'd
'd
matches the characters 'd literally (case sensitive)
2nd Alternative
[[:lower:]](\.|\!|\?) ?"?[[:lower:]]
Match a single character present in the list below
[[:lower:]]
[:lower:] matches a lowercase letter [a-z]
2nd Capturing Group
(\.|\!|\?)
1st Alternative
\.
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
2nd Alternative
\!
\! matches the character ! with index 3310 (2116 or 418) literally (case sensitive)
3rd Alternative
\?
\? matches the character ? with index 6310 (3F16 or 778) literally (case sensitive)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
"
matches the character " with index 3410 (2216 or 428) literally (case sensitive)
Match a single character present in the list below
[[:lower:]]
[:lower:] matches a lowercase letter [a-z]
3rd Alternative
(\w|"),"?\w
3rd Capturing Group
(\w|")
1st Alternative
\w
\w matches any word character (equivalent to [a-zA-Z0-9_])
2nd Alternative
"
" matches the character " with index 3410 (2216 or 428) literally (case sensitive)
, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
"
matches the character " with index 3410 (2216 or 428) literally (case sensitive)
\w matches any word character (equivalent to [a-zA-Z0-9_])
4th Alternative
( |^)"?(i|"|'|,|\!|\?|\.)(\s|")
4th Capturing Group
( |^)
1st Alternative
matches the character with index 3210 (2016 or 408) literally (case sensitive)
2nd Alternative
^
^ asserts position at start of a line
"
matches the character " with index 3410 (2216 or 428) literally (case sensitive)
5th Capturing Group
(i|"|'|,|\!|\?|\.)
1st Alternative
i
i matches the character i with index 10510 (6916 or 1518) literally (case sensitive)
2nd Alternative
"
" matches the character " with index 3410 (2216 or 428) literally (case sensitive)
3rd Alternative
'
' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
4th Alternative
,
, matches the character , with index 4410 (2C16 or 548) literally (case sensitive)
5th Alternative
\!
\! matches the character ! with index 3310 (2116 or 418) literally (case sensitive)
6th Alternative
\?
\? matches the character ? with index 6310 (3F16 or 778) literally (case sensitive)
7th Alternative
\.
6th Capturing Group
(\s|")
1st Alternative
\s
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
2nd Alternative
"
" matches the character " with index 3410 (2216 or 428) literally (case sensitive)
5th Alternative
_
_ matches the character _ with index 9510 (5F16 or 1378) literally (case sensitive)
6th Alternative
(|)
7th Capturing Group
(|)
1st Alternative
matches the character with index 822010 (201C16 or 200348) literally (case sensitive)
2nd Alternative
matches the character with index 822110 (201D16 or 200358) literally (case sensitive)
7th Alternative
\|
\| matches the character | with index 12410 (7C16 or 1748) 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