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
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
^\s*(?:(?:kind(?:est)* )*regards?|cheers?|greetings?|thanks|thank you)\b,?.*[{0,2}\r\n].*(?:[*.!?: ]|$)
/
gim
^ asserts position at start of a line
\s
matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:(?:kind(?:est)* )*regards?|cheers?|greetings?|thanks|thank you)
1st Alternative
(?:kind(?:est)* )*regards?
Non-capturing group
(?:kind(?:est)* )*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
kind matches the characters kind literally (case insensitive)
Non-capturing group
(?:est)*
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
est matches the characters est literally (case insensitive)
matches the character literally (case insensitive)
regard matches the characters regard literally (case insensitive)
s
matches the character s literally (case insensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
2nd Alternative
cheers?
cheer matches the characters cheer literally (case insensitive)
s
matches the character s literally (case insensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
3rd Alternative
greetings?
greeting matches the characters greeting literally (case insensitive)
s
matches the character s literally (case insensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
4th Alternative
thanks
thanks matches the characters thanks literally (case insensitive)
5th Alternative
thank you
thank you matches the characters thank you literally (case insensitive)
\b assert position at a word boundary: (^\w|\w$|\W\w|\w\W)
,
matches the character , literally (case insensitive)
? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[\r\n]
{0,2} matches the previous token between 0 and 2 times, as many times as possible, giving back as needed (greedy)
\r matches a carriage return (ASCII 13)
\n matches a line-feed (newline) character (ASCII 10)
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Non-capturing group
(?:[*.!?: ]|$)
1st Alternative
[*.!?: ]
2nd Alternative
$
Global pattern flags
g modifier: global. All matches (don't return after first match)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
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.

Regular Expression
No Match

/
/
gim

Test String