1

I have the following regular expression to match an email address:

^([a-zA-Z0-9])+([a-zA-Z0-9._%+-])+@([a-zA-Z0-9_.-])+\.(([a-zA-Z]){2,6})$

How can I modify this if I want to match everything BUT an email address? Instinctively, I think of something like

!(^([a-zA-Z0-9])+([a-zA-Z0-9._%+-])+@([a-zA-Z0-9_.-])+\.(([a-zA-Z]){2,6})$)

but I know that's not how regular expressions work.

noclist
  • 1,368
  • 1
  • 18
  • 46

1 Answers1

0

Match anything other than an email address

^(?![a-zA-Z0-9])+([a-zA-Z0-9._%+-])+@([a-zA-Z0-9_.-])+\.(([a‌​-zA-Z]){2,6}$).+$

^        # BOS
         # Not an email address
(?![a-zA-Z0-9])+([a-zA-Z0-9._%+-])+@([a-zA-Z0-9_.-])+\.(([a‌​-zA-Z]){2,6}$)
.+       # Ok, match whatever this string contains
$        # EOS