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
"
construit \w{2,4} (lieu|sein|plusieurs|parpaings|face|forme|immeuble|(\d+|\w{2,10}) ([ée]tapes|phases)|ossature|siporex|plaques|charpente|rez.*|rdc|cloison|\d+ fois|r\+\d+)
"
gm
construit
matches the characters construit literally (case sensitive)
\w
matches any word character (equivalent to [a-zA-Z0-9_])
{2,4} matches the previous token between 2 and 4 times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
1st Capturing Group
(lieu|sein|plusieurs|parpaings|face|forme|immeuble|(\d+|\w{2,10}) ([ée]tapes|phases)|ossature|siporex|plaques|charpente|rez.*|rdc|cloison|\d+ fois|r\+\d+)
1st Alternative
lieu
lieu
matches the characters lieu literally (case sensitive)
2nd Alternative
sein
sein
matches the characters sein literally (case sensitive)
3rd Alternative
plusieurs
plusieurs
matches the characters plusieurs literally (case sensitive)
4th Alternative
parpaings
parpaings
matches the characters parpaings literally (case sensitive)
5th Alternative
face
face
matches the characters face literally (case sensitive)
6th Alternative
forme
forme
matches the characters forme literally (case sensitive)
7th Alternative
immeuble
immeuble
matches the characters immeuble literally (case sensitive)
8th Alternative
(\d+|\w{2,10}) ([ée]tapes|phases)
2nd Capturing Group
(\d+|\w{2,10})
1st Alternative
\d+
\d
matches a digit (equivalent to [0-9])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
2nd Alternative
\w{2,10}
\w
matches any word character (equivalent to [a-zA-Z0-9_])
{2,10} matches the previous token between 2 and 10 times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
3rd Capturing Group
([ée]tapes|phases)
1st Alternative
[ée]tapes
Match a single character present in the list below
[ée]
ée
matches a single character in the list ée (case sensitive)
tapes
matches the characters tapes literally (case sensitive)
2nd Alternative
phases
9th Alternative
ossature
ossature
matches the characters ossature literally (case sensitive)
10th Alternative
siporex
11th Alternative
plaques
12th Alternative
charpente
13th Alternative
rez.*
14th Alternative
rdc
15th Alternative
cloison
16th Alternative
\d+ fois
17th Alternative
r\+\d+
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