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
/
<multiline label="Description">\s<p>.*<\/p>\s<p>(?'welcomeLine'.+)<\/p>.*<tr class="odd">\s<td>(?'case_id'\d+)<\/td>\s<td>\s(?'status'\w+)\s<\/td>\s<td>(?'case_date'[a-z\s0-9,]+)<\/td>\s<td>(?'amount'[0-9.]+)<\/td>\s<td>(?'descriptor'[a-z0-9.\s]+).*
/
gmis
<multiline label="Description">
matches the characters <multiline label="Description"> literally (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
<p>
matches the characters <p> literally (case insensitive)
.
matches any character
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
< matches the character < with index 6010 (3C16 or 748) literally (case insensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case insensitive)
p>
matches the characters p> literally (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
<p>
matches the characters <p> literally (case insensitive)
Named Capture Group welcomeLine
(?'welcomeLine'.+)
.
matches any character
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
< matches the character < with index 6010 (3C16 or 748) literally (case insensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case insensitive)
p>
matches the characters p> literally (case insensitive)
.
matches any character
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
<tr class="odd">
matches the characters <tr class="odd"> literally (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
<td>
matches the characters <td> literally (case insensitive)
Named Capture Group case_id
(?'case_id'\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)
< matches the character < with index 6010 (3C16 or 748) literally (case insensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case insensitive)
td>
matches the characters td> literally (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
<td>
matches the characters <td> literally (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
Named Capture Group status
(?'status'\w+)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
< matches the character < with index 6010 (3C16 or 748) literally (case insensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case insensitive)
td>
matches the characters td> literally (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
<td>
matches the characters <td> literally (case insensitive)
Named Capture Group case_date
(?'case_date'[a-z\s0-9,]+)
< matches the character < with index 6010 (3C16 or 748) literally (case insensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case insensitive)
td>
matches the characters td> literally (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
<td>
matches the characters <td> literally (case insensitive)
Named Capture Group amount
(?'amount'[0-9.]+)
< matches the character < with index 6010 (3C16 or 748) literally (case insensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case insensitive)
td>
matches the characters td> literally (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
<td>
matches the characters <td> literally (case insensitive)
Named Capture Group descriptor
(?'descriptor'[a-z0-9.\s]+)
.
matches any character
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)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
s modifier: single line. Dot matches newline characters
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gmis

Test String