Regular Expressions 101

@regex101
Donate
Sponsor
Contact
Bug Reports & Feedback
Wiki
Whats new?

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python 2.7
  • Golang (RE2)

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
((?<=\.)|\s*^)\s*(I )?hope (it|this|that)( will\b| can\b)? helps?( (you|someone(?:\h*else)?)\b)?(:-?\)|🙂️|[!.;,\s])*?(\s*(cheers|good ?luck)([!,.]*))?$
/
gmi
1st Capturing Group
((?<=\.)|\s*^)
1st Alternative
(?<=\.)
Positive Lookbehind
(?<=\.)
Assert that the Regex below matches
\. matches the character . literally (case insensitive)
2nd Alternative
\s*^
\s*
matches any whitespace character (equal to [\r\n\t\f\v ])
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
^ asserts position at start of a line
\s*
matches any whitespace character (equal to [\r\n\t\f\v ])
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
2nd Capturing Group
(I )?
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
I matches the characters I literally (case insensitive)
hope matches the characters hope literally (case insensitive)
3rd Capturing Group
(it|this|that)
1st Alternative
it
it matches the characters it literally (case insensitive)
2nd Alternative
this
this matches the characters this literally (case insensitive)
3rd Alternative
that
that matches the characters that literally (case insensitive)
4th Capturing Group
( will\b| can\b)?
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
1st Alternative
will\b
will matches the characters will literally (case insensitive)
\b assert position at a word boundary: (^\\w|\\w$|\\W\\w|\\w\\W)
2nd Alternative
can\b
can matches the characters can literally (case insensitive)
\b assert position at a word boundary: (^\\w|\\w$|\\W\\w|\\w\\W)
help matches the characters help literally (case insensitive)
s?
matches the character s literally (case insensitive)
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
5th Capturing Group
( (you|someone(?:\h*else)?)\b)?
? Quantifier — Matches between zero and one times, as many times as possible, giving back as needed (greedy)
matches the character literally (case insensitive)
6th Capturing Group
(you|someone(?:\h*else)?)
\b assert position at a word boundary: (^\\w|\\w$|\\W\\w|\\w\\W)
7th Capturing Group
(:-?\)|🙂️|[!.;,\s])*?
8th Capturing Group
(\s*(cheers|good ?luck)([!,.]*))?
$ asserts position at the end of a line
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)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
Your regular expression does not match the subject string.Try launching the debugger to find out why.

Regular Expression
No Match

/
/
gmi

Test String