Regular Expressions 101

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
<li><a href=".*\.html" title=".*">.* (?:(?!\b(22|9|13|23|4|15)\b).)*<\/a><\/li>$
/
gm
<li><a href="
matches the characters <li><a href=" literally (case sensitive)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\. matches the character . with index 4610 (2E16 or 568) literally (case sensitive)
html" title="
matches the characters html" title=" literally (case sensitive)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
">
matches the characters "> literally (case sensitive)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
matches the character with index 3210 (2016 or 408) literally (case sensitive)
Non-capturing group
(?:(?!\b(22|9|13|23|4|15)\b).)*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Negative Lookahead
(?!\b(22|9|13|23|4|15)\b)
Assert that the Regex below does not match
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
1st Capturing Group
(22|9|13|23|4|15)
1st Alternative
22
22
matches the characters 22 literally (case sensitive)
2nd Alternative
9
9 matches the character 9 with index 5710 (3916 or 718) literally (case sensitive)
3rd Alternative
13
13
matches the characters 13 literally (case sensitive)
4th Alternative
23
23
matches the characters 23 literally (case sensitive)
5th Alternative
4
4 matches the character 4 with index 5210 (3416 or 648) literally (case sensitive)
6th Alternative
15
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
. matches any character (except for line terminators)
< matches the character < with index 6010 (3C16 or 748) literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
a><
matches the characters a>< literally (case sensitive)
\/ matches the character / with index 4710 (2F16 or 578) literally (case sensitive)
li>
matches the characters li> literally (case sensitive)
$ asserts position at the end of a line
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.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String