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|)([A--ÚÑ][^¿¡\!\?\.]+)((\.{3})?\?)
"
g
1st Capturing Group
(^|[\.\?\!\-]\s|)
1st Alternative
^
^ asserts position at start of the string
2nd Alternative
[\.\?\!\-]\s
Match a single character present in the list below
[\.\?\!\-]
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
\? matches the character ? with index 6310 (3F16 or 778) literally (case sensitive)
\! matches the character ! with index 3310 (2116 or 418) literally (case sensitive)
\- matches the character - with index 4510 (2D16 or 558) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
3rd Alternative null, matches any position
2nd Capturing Group
([A--ÚÑ][^¿¡\!\?\.]+)
Match a single character present in the list below
[A--ÚÑ]
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
à matches the character à with index 19510 (C316 or 3038) literally (case sensitive)
 matches a single character in the range between  (index 129) and à (index 195) (case sensitive)
šÃ‘
matches a single character in the list šÃ‘ (case sensitive)
Match a single character not present in the list below
[^¿¡\!\?\.]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
¿¡
matches a single character in the list ¿¡ (case sensitive)
\! matches the character ! with index 3310 (2116 or 418) literally (case sensitive)
\? matches the character ? with index 6310 (3F16 or 778) literally (case sensitive)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
3rd Capturing Group
((\.{3})?\?)
4th Capturing Group
(\.{3})?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\.
matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
{3} matches the previous token exactly 3 times
\? matches the character ? with index 6310 (3F16 or 778) literally (case sensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
g

Test String

Substitution

Processing...