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
/
([[:space:]])(vais|vas|va|allons|allez|vont)([[:space:]])([^\Qchez\E][^\Qassez\E][[:alpha:]]*)(z)([[:space:]]|[[:punct:]])
/
g
1st Capturing Group
([[:space:]])
Match a single character present in the list below
[[:space:]]
[:space:] matches a whitespace character, including a line break [ \t\r\n\v\f] (also written as \s)
2nd Capturing Group
(vais|vas|va|allons|allez|vont)
1st Alternative
vais
vais
matches the characters vais literally (case sensitive)
2nd Alternative
vas
vas
matches the characters vas literally (case sensitive)
3rd Alternative
va
va
matches the characters va literally (case sensitive)
4th Alternative
allons
allons
matches the characters allons literally (case sensitive)
5th Alternative
allez
allez
matches the characters allez literally (case sensitive)
6th Alternative
vont
vont
matches the characters vont literally (case sensitive)
3rd Capturing Group
([[:space:]])
Match a single character present in the list below
[[:space:]]
[:space:] matches a whitespace character, including a line break [ \t\r\n\v\f] (also written as \s)
4th Capturing Group
([^\Qchez\E][^\Qassez\E][[:alpha:]]*)
Match a single character not present in the list below
[^\Qchez\E]
\Qchez\E matches a single character in the list chez (case sensitive)
Match a single character not present in the list below
[^\Qassez\E]
\Qassez\E matches a single character in the list asez (case sensitive)
Match a single character present in the list below
[[:alpha:]]
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
[:alpha:] matches a alphabetic character [a-zA-Z]
5th Capturing Group
(z)
z matches the character z with index 12210 (7A16 or 1728) literally (case sensitive)
6th Capturing Group
([[:space:]]|[[:punct:]])
1st Alternative
[[:space:]]
Match a single character present in the list below
[[:space:]]
[:space:] matches a whitespace character, including a line break [ \t\r\n\v\f] (also written as \s)
2nd Alternative
[[:punct:]]
Match a single character present in the list below
[[:punct:]]
[:punct:] matches a punctuation character [!"#$%&'()*+,\-./:;<=>?@[\]^_`{|}~]
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
g

Test String