I need to find everything in a string that is not an e-mail address.
Here is my version of how to find an e-mail address.
^[a-zA-Z0-9_.-]+@[a-zA-Z0-9][a-zA-Z0-9-.]+\.([a-zA-Z]{2,6})$
I want to modify this regex to find the inverse–everything other than the e-mail address in any string.
###Example 1:
asdasd
###Example 2:
123@asd.com sda
Note: I want to get status == true in the following line:
var status = myString.match(pattern matches everything that is not an email address);
###I can only change the pattern, nothing else!
The official standard is known as RFC 2822. Regex pattern for email address is then:
More practical implementation of RFC 2822 (if we omit the syntax using double quotes and square brackets), which will still match 99.99% of all email addresses in actual use today, is:
To get list of non-matching "words" from
myStringuse JavaScript code:Check this demo.