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
/
^Header 1$(?:\R(?!Header ).*+)*?\RNombre : Juan$(?:\R(?!Header ).*+)*
/
mig
^ asserts position at start of a line
Header 1
matches the characters Header 1 literally (case insensitive)
$ asserts position at the end of a line
Non-capturing group
(?:\R(?!Header ).*+)*?
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
\R matches any Unicode newline sequence
Negative Lookahead
(?!Header )
Assert that the Regex below does not match
Header
matches the characters Header literally (case insensitive)
.
matches any character (except for line terminators)
*+ matches the previous token between zero and unlimited times, as many times as possible, without giving back (possessive)
\R matches any Unicode newline sequence
Nombre : Juan
matches the characters Nombre : Juan literally (case insensitive)
$ asserts position at the end of a line
Non-capturing group
(?:\R(?!Header ).*+)*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
\R matches any Unicode newline sequence
Negative Lookahead
(?!Header )
Assert that the Regex below does not match
Header
matches the characters Header literally (case insensitive)
.
matches any character (except for line terminators)
*+ matches the previous token between zero and unlimited times, as many times as possible, without giving back (possessive)
Global pattern flags
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
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

/
/
mig

Test String