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
~
(?s)<body>\K\s*<tag(?:(?!<inner_block=25>).)+</tag>
~
(?s)
match the remainder of the pattern with the following effective flags: s
s modifier: single line. Dot matches newline characters
<body>
matches the characters <body> literally (case sensitive)
\K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
<tag
matches the characters <tag literally (case sensitive)
Non-capturing group
(?:(?!<inner_block=25>).)+
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
Negative Lookahead
(?!<inner_block=25>)
Assert that the Regex below does not match
<inner_block=25>
matches the characters <inner_block=25> literally (case sensitive)
. matches any character
</tag>
matches the characters </tag> literally (case sensitive)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

~
~

Test String

Substitution

Processing...

Regex Debugger

Please wait while your expression is being debugged...