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@"](\.[^<>()[\].,;:\s@"])*|"[^\n"]")@(?:[^<>()[\].,;:\s@"]\.)+[^<>()[\]\.,;:\s@"]$
/
img
^ asserts position at start of a line
Non-capturing group
(?:[^<>()[\].,;:\s@"](\.[^<>()[\].,;:\s@"])*|"[^\n"]")
1st Alternative
[^<>()[\].,;:\s@"](\.[^<>()[\].,;:\s@"])*
Match a single character not present in the list below
[^<>()[\].,;:\s@"]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
<>()[ matches a single character in the list <>()[ (case insensitive)
\] matches the character ] literally (case insensitive)
.,;: matches a single character in the list .,;: (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
@" matches a single character in the list @" (case insensitive)
1st Capturing Group
(\.[^<>()[\].,;:\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
\. matches the character . literally (case insensitive)
Match a single character not present in the list below
[^<>()[\].,;:\s@"]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
<>()[ matches a single character in the list <>()[ (case insensitive)
\] matches the character ] literally (case insensitive)
.,;: matches a single character in the list .,;: (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
@" matches a single character in the list @" (case insensitive)
2nd Alternative
"[^\n"]"
" matches the character " literally (case insensitive)
Match a single character not present in the list below
[^\n"]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\n matches a line-feed (newline) character (ASCII 10)
" matches the character " literally (case insensitive)
" matches the character " literally (case insensitive)
@ matches the character @ literally (case insensitive)
Non-capturing group
(?:[^<>()[\].,;:\s@"]\.)+
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character not present in the list below
[^<>()[\].,;:\s@"]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
<>()[ matches a single character in the list <>()[ (case insensitive)
\] matches the character ] literally (case insensitive)
.,;: matches a single character in the list .,;: (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
@" matches a single character in the list @" (case insensitive)
\. matches the character . literally (case insensitive)
Match a single character not present in the list below
[^<>()[\]\.,;:\s@"]
{2,63} matches the previous token between 2 and 63 times, as many times as possible, giving back as needed (greedy)
<>()[ matches a single character in the list <>()[ (case insensitive)
\] matches the character ] literally (case insensitive)
\. matches the character . literally (case insensitive)
,;: matches a single character in the list ,;: (case insensitive)
\s matches any whitespace character (equivalent to [\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
@" matches a single character in the list @" (case insensitive)
$ asserts position at the end of a line
Global pattern flags
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)
g modifier: global. All matches (don't return after first match)
Your regular expression does not match the subject string.

Regular Expression
No Match

/
/
img

Test String