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
/
(\n\s|\s\n)
/
g
1st Capturing Group
(\n\s|\s\n)
1st Alternative
\n\s
\n matches a line-feed (newline) character (ASCII 10)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
2nd Alternative
\s\n
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
\n matches a line-feed (newline) character (ASCII 10)
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