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
"
\d*((\s)?(|m|M)) de bureaux?|bureaux? d'une surface de \d*((\s)?(|m|M))|bureaux? de \d*((\s)?(|m|M))
"
gm
1st Alternative
\d*((\s)?(|m|M)) de bureaux?
\d
matches a digit (equivalent to [0-9])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
1st Capturing Group
((\s)?(|m|M))
2nd Capturing Group
(\s)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
3rd Capturing Group
(|m|M)
1st Alternative
matches the characters literally (case sensitive)
2nd Alternative
m
m matches the character m with index 10910 (6D16 or 1558) literally (case sensitive)
3rd Alternative
M
M matches the character M with index 7710 (4D16 or 1158) literally (case sensitive)
de bureau
matches the characters de bureau literally (case sensitive)
x
matches the character x with index 12010 (7816 or 1708) literally (case sensitive)
2nd Alternative
bureaux? d'une surface de \d*((\s)?(|m|M))
bureau
matches the characters bureau literally (case sensitive)
x
matches the character x with index 12010 (7816 or 1708) literally (case sensitive)
d'une surface de
matches the characters d'une surface de literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
4th Capturing Group
((\s)?(|m|M))
5th Capturing Group
(\s)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
6th Capturing Group
(|m|M)
1st Alternative
matches the characters literally (case sensitive)
2nd Alternative
m
m matches the character m with index 10910 (6D16 or 1558) literally (case sensitive)
3rd Alternative
M
M matches the character M with index 7710 (4D16 or 1158) literally (case sensitive)
3rd Alternative
bureaux? de \d*((\s)?(|m|M))
bureau
matches the characters bureau literally (case sensitive)
x
matches the character x with index 12010 (7816 or 1708) literally (case sensitive)
de
matches the characters de literally (case sensitive)
\d
matches a digit (equivalent to [0-9])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
7th Capturing Group
((\s)?(|m|M))
8th Capturing Group
(\s)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
9th Capturing Group
(|m|M)
1st Alternative
matches the characters literally (case sensitive)
2nd Alternative
m
m matches the character m with index 10910 (6D16 or 1558) literally (case sensitive)
3rd Alternative
M
M matches the character M with index 7710 (4D16 or 1158) 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.

Regular Expression
No Match

r"
"
gm

Test String