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
"
(?i)((\bfoll[\wá-ú]{4,10})|(\bfoll([aeéoó][nsdr]?(?=[^\wáé])))|(\bfoll(?:([eéaá][ibsrdo][\wáé])))|(folleta))
"
gm
(?i)
match the remainder of the pattern with the following effective flags: gmi
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
1st Capturing Group
((\bfoll[\wá-ú]{4,10})|(\bfoll([aeéoó][nsdr]?(?=[^\wáé])))|(\bfoll(?:([eéaá][ibsrdo][\wáé])))|(folleta))
1st Alternative
(\bfoll[\wá-ú]{4,10})
2nd Capturing Group
(\bfoll[\wá-ú]{4,10})
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
foll
matches the characters foll literally (case insensitive)
Match a single character present in the list below
[\wá-ú]
{4,10} matches the previous token between 4 and 10 times, as many times as possible, giving back as needed (greedy)
\w matches any word character (equivalent to [a-zA-Z0-9_])
à matches the character à with index 19510 (C316 or 3038) literally (case insensitive)
¡-à matches a single character in the range between ¡ (index 161) and à (index 195) (case insensitive)
º matches the character º with index 18610 (BA16 or 2728) literally (case insensitive)
2nd Alternative
(\bfoll([aeéoó][nsdr]?(?=[^\wáé])))
3rd Capturing Group
(\bfoll([aeéoó][nsdr]?(?=[^\wáé])))
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
foll
matches the characters foll literally (case insensitive)
4th Capturing Group
([aeéoó][nsdr]?(?=[^\wáé]))
Match a single character present in the list below
[aeéoó]
aeéoó
matches a single character in the list aeéo³ (case insensitive)
Match a single character present in the list below
[nsdr]
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
nsdr
matches a single character in the list nsdr (case insensitive)
Positive Lookahead
(?=[^\wáé])
Assert that the Regex below matches
Match a single character not present in the list below
[^\wáé]
\w matches any word character (equivalent to [a-zA-Z0-9_])
áé
matches a single character in the list á© (case insensitive)
3rd Alternative
(\bfoll(?:([eéaá][ibsrdo][\wáé])))
5th Capturing Group
(\bfoll(?:([eéaá][ibsrdo][\wáé])))
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
foll
matches the characters foll literally (case insensitive)
Non-capturing group
(?:([eéaá][ibsrdo][\wáé]))
6th Capturing Group
([eéaá][ibsrdo][\wáé])
Match a single character present in the list below
[eéaá]
eéaá
matches a single character in the list eéa¡ (case insensitive)
Match a single character present in the list below
[ibsrdo]
ibsrdo
matches a single character in the list ibsrdo (case insensitive)
Match a single character present in the list below
[\wáé]
\w matches any word character (equivalent to [a-zA-Z0-9_])
áé
matches a single character in the list á© (case insensitive)
4th Alternative
(folleta)
7th Capturing Group
(folleta)
folleta
matches the characters folleta 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)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
gm

Test String

Substitution

Processing...