Regular Expressions 101

@regex101
Donate
Sponsor
Contact
Bug Reports & Feedback
Wiki
Whats new?

Save & Share

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

Flavor

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

Function

  • Match
  • Substitution
  • List
  • Unit Tests
~
<c>(<.>)?(?(1).</c>).(</c>)?(?2)
~
g
<c> matches the characters <c> literally (case sensitive)
1st Capturing Group
(<.>)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
< matches the character < literally (case sensitive)
. matches any character (except for line terminators)
> matches the character > literally (case sensitive)
Conditional
(?(1).</c>)
Conditionally matches one of two options depending on whether the 1st capturing group matched
If condition is met, match the following regex
.</c>
.
matches any character (except for line terminators)
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)
</c> matches the characters </c> literally (case sensitive)
.
matches any character (except for line terminators)
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)
2nd Capturing Group
(</c>)?
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
</c> matches the characters </c> literally (case sensitive)
(?2)
recurses the 2nd subpattern
++ matches the previous token between one and unlimited times, as many times as possible, without giving back (possessive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

~
~
g

Test String