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) +|^ +(?=\s)| (?= +[\n\0])
"
g
1st Alternative
(?<=\s) +
Positive Lookbehind
(?<=\s)
Assert that the Regex below matches
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
matches the character with index 3210 (2016 or 408) literally (case sensitive)
2nd Alternative
^ +(?=\s)
^ asserts position at start of the string
matches the character with index 3210 (2016 or 408) literally (case sensitive)
Positive Lookahead
(?=\s)
Assert that the Regex below matches
\s matches any whitespace character (equivalent to [\r\n\t\f\v  ])
3rd Alternative
(?= +[\n\0])
matches the character with index 3210 (2016 or 408) literally (case sensitive)
Positive Lookahead
(?= +[\n\0])
Assert that the Regex below matches
matches the character with index 3210 (2016 or 408) literally (case sensitive)
Match a single character present in the list below
[\n\0]
\n matches a line-feed (newline) character (ASCII 10)
\0 matches the character with index 08 (010 or 016) literally (case sensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.

Regular Expression
No Match

r"
"
g

Test String