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
/
(^From\:\s|(?!^)\G).*?(\n\s+(.*?))*\K[^\x00-\x7F]
/
gm
1st Capturing Group
(^From\:\s|(?!^)\G)
1st Alternative
^From\:\s
^ asserts position at start of a line
From
matches the characters From literally (case sensitive)
\: matches the character : with index 5810 (3A16 or 728) literally (case sensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v ])
2nd Alternative
(?!^)\G
Negative Lookahead
(?!^)
Assert that the Regex below does not match
^ asserts position at start of a line
\G asserts position at the end of the previous match or the start of the string for the first match
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
2nd Capturing Group
(\n\s+(.*?))*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you're not interested in the data
\n matches a line-feed (newline) character (ASCII 10)
\s
matches any whitespace character (equivalent to [\r\n\t\f\v ])
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
3rd Capturing Group
(.*?)
.
matches any character (except for line terminators)
*? matches the previous token between zero and unlimited times, as few times as possible, expanding as needed (lazy)
\K resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
Match a single character not present in the list below
[^\x00-\x7F]
\x00-\x7F matches a single character in the range between (index 0) and  (index 127) (case sensitive)
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gm

Test String

Substitution

Processing...