I need a regex to match something this:
<a space><any character/s>@<any character/s><a space>
Yes, it's a very very basic email parser.
Thanks!
I need a regex to match something this:
<a space><any character/s>@<any character/s><a space>
Yes, it's a very very basic email parser.
Thanks!
The square brackets indicate a character class, which is the characters that can be present there. So, your regex would match .@.
or *@*
. Instead, try "\ .*@.*\
" (quotes to show the space at the end, don't include them inside your regex.
For testing e-mail, you might use the regex described here:
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b
It still doesn't cover 100% of e-mails, but the comprehensive version is fairly involved.
^ .+@.+ $
This translates to "the start of the string is followed by a space, one or more characters, the @ symbol, one or more characters, and the last character in the string is a space."