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
/
^ (?=(a(?-1)?b)) a+ (?=(b(?-1)?c)) (b(?-1)?c) $
/
gx
^ asserts position at start of the string
Positive Lookahead
(?=(a(?-1)?b))
Assert that the Regex below matches
1st Capturing Group
(a(?-1)?b)
a matches the character a with index 9710 (6116 or 1418) literally (case sensitive)
(?-1)
recurses the 1st subpattern
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
b matches the character b with index 9810 (6216 or 1428) literally (case sensitive)
a
matches the character a with index 9710 (6116 or 1418) literally (case sensitive)
Positive Lookahead
(?=(b(?-1)?c))
Assert that the Regex below matches
2nd Capturing Group
(b(?-1)?c)
b matches the character b with index 9810 (6216 or 1428) literally (case sensitive)
(?-1)
recurses the 2nd subpattern
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
c matches the character c with index 9910 (6316 or 1438) literally (case sensitive)
3rd Capturing Group
(b(?-1)?c)
b matches the character b with index 9810 (6216 or 1428) literally (case sensitive)
(?-1)
recurses the 3rd subpattern
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
c matches the character c with index 9910 (6316 or 1438) literally (case sensitive)
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
Global pattern flags
g modifier: global. All matches (don't return after first match)
x modifier: extended. Spaces and text after a # in the pattern are ignored
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gx

Test String