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
"
(Seg\.?u?r?i?d?a?d? 24\s?ho?r?a?s|Prosegur|adt)
"
gmi
1st Capturing Group
(Seg\.?u?r?i?d?a?d? 24\s?ho?r?a?s|Prosegur|adt)
1st Alternative
Seg\.?u?r?i?d?a?d? 24\s?ho?r?a?s
Seg
matches the characters Seg literally (case insensitive)
\.
matches the character . with index 4610 (2E16 or 568) literally (case insensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
u
matches the character u with index 11710 (7516 or 1658) literally (case insensitive)
r
matches the character r with index 11410 (7216 or 1628) literally (case insensitive)
i
matches the character i with index 10510 (6916 or 1518) literally (case insensitive)
d
matches the character d with index 10010 (6416 or 1448) literally (case insensitive)
a
matches the character a with index 9710 (6116 or 1418) literally (case insensitive)
d
matches the character d with index 10010 (6416 or 1448) literally (case insensitive)
24
matches the characters 24 literally (case insensitive)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v  ])
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
h matches the character h with index 10410 (6816 or 1508) literally (case insensitive)
o
matches the character o with index 11110 (6F16 or 1578) literally (case insensitive)
r
matches the character r with index 11410 (7216 or 1628) literally (case insensitive)
a
matches the character a with index 9710 (6116 or 1418) literally (case insensitive)
s matches the character s with index 11510 (7316 or 1638) literally (case insensitive)
2nd Alternative
Prosegur
Prosegur
matches the characters Prosegur literally (case insensitive)
3rd Alternative
adt
adt
matches the characters adt literally (case insensitive)
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)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
gmi

Test String