I have an input field that will take a keyword input as either an email address or a plain text keyword. I just want to validate that there's no unusual or unsafe characters. My normal validation expression I use for emails on the webform is:
"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
However, I need an expression that will also take a plain word such as "Blanket". So, I need the expression to take all of the characters of a normal email address but not to validate the sequence that they're in. I've always been horrible at regular expressions. Thanks for your help, Chris.
Just do this:
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*|\w+
|
means or .
So the above regex matches emails or plain words.
I have an input field that will take a keyword input as either an email address or a plain text keyword.
You shouldn't be trying to validate e-mail addresses using a regexp.
The e-mail address format is covered by RFC 5322 and if you where to try and write a regexp that goes close to matching that spec, you would need a regexp that looks something like this:
The easiest way to validate an e-mail address is to send an e-mail to that address.
thanks for the question
\w+([-+.']\w+)*@\w+([-.]*)
i hope this be helpful
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.