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
'
(?sm)span class=\'Finish F(\d{1,2}).*?<td style="text-align:center">(\d{1,2}e*).*?target="_blank">(.+?)</a>.*?<td class=\'trainer\'>.*?target="_blank">(.+?)</a>.*?<td class=\'jockey\'>.*?<span class=\'Hilite\'>(.+?)</span></a>.*?<td style="text-align:center">(.*?)</td>.*?<td style="text-align:center">(.*?)</td>.*?<td>(.*?)</td>.*?<td>(.*?)</td>.*?<td>(.*?)</td>
'
gm
(?sm)
match the remainder of the pattern with the following effective flags: gms
s modifier: single line. Dot matches newline characters
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
span class=
matches the characters span class= literally (case sensitive)
\' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
Finish F
matches the characters Finish F literally (case sensitive)
1st Capturing Group
(\d{1,2})
\d
matches a digit (equivalent to [0-9])
{1,2} matches the previous token between 1 and 2 times, as many times as possible, giving back as needed (greedy)
.
matches any character
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
<td style="text-align:center">
matches the characters <td style="text-align:center"> literally (case sensitive)
2nd Capturing Group
(\d{1,2}e*)
\d
matches a digit (equivalent to [0-9])
{1,2} matches the previous token between 1 and 2 times, as many times as possible, giving back as needed (greedy)
e
matches the character e with index 10110 (6516 or 1458) literally (case sensitive)
.
matches any character
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
target="_blank">
matches the characters target="_blank"> literally (case sensitive)
3rd Capturing Group
(.+?)
.
matches any character
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)
</a>
matches the characters </a> literally (case sensitive)
.
matches any character
<td class=
matches the characters <td class= literally (case sensitive)
\' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
trainer
matches the characters trainer literally (case sensitive)
\' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
> matches the character > with index 6210 (3E16 or 768) literally (case sensitive)
.
matches any character
target="_blank">
matches the characters target="_blank"> literally (case sensitive)
4th Capturing Group
(.+?)
</a>
matches the characters </a> literally (case sensitive)
.
matches any character
<td class=
matches the characters <td class= literally (case sensitive)
\' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
jockey
matches the characters jockey literally (case sensitive)
\' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
> matches the character > with index 6210 (3E16 or 768) literally (case sensitive)
.
matches any character
<span class=
matches the characters <span class= literally (case sensitive)
\' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
Hilite
matches the characters Hilite literally (case sensitive)
\' matches the character ' with index 3910 (2716 or 478) literally (case sensitive)
> matches the character > with index 6210 (3E16 or 768) literally (case sensitive)
5th Capturing Group
(.+?)
</span></a>
matches the characters </span></a> literally (case sensitive)
.
matches any character
<td style="text-align:center">
matches the characters <td style="text-align:center"> literally (case sensitive)
6th Capturing Group
(.*?)
</td>
matches the characters </td> literally (case sensitive)
.
matches any character
<td style="text-align:center">
matches the characters <td style="text-align:center"> literally (case sensitive)
7th Capturing Group
(.*?)
</td>
matches the characters </td> literally (case sensitive)
.
matches any character
<td>
matches the characters <td> literally (case sensitive)
8th Capturing Group
(.*?)
</td>
matches the characters </td> literally (case sensitive)
.
matches any character
<td>
matches the characters <td> literally (case sensitive)
9th Capturing Group
(.*?)
</td>
matches the characters </td> literally (case sensitive)
.
matches any character
<td>
matches the characters <td> literally (case sensitive)
10th Capturing Group
(.*?)
</td>
matches the characters </td> 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