我需要的不是电子邮件验证.. 其简单。 允许@hello.world
或@hello_world
或@helloworld
但@helloworld.
应被视为@helloworld
从而@helloworld?
PHP正则表达式用于检查A-Z a-z 0-9 _和
在为之后的字母或数字的短检查。并且_如果不是,则先取前面的字符串。
我现有的RegEx是/@.([A-Za-z0-9_]+)(?=\?|\,|\;|\s|\Z)/
它只关心@helloworld而不是@ hello.world或@hello_world。
更新:
所以现在我有一个正则表达式与问题号1交易,即允许@hello.world
或@hello_world
或@helloworld
但还是什么@helloworld.
应被视为@helloworld
从而@helloworld?
新正则表达式:
/@([A-Za-z0-9+_.-]+)/
谷歌“的电子邮件正则表达式”你会发现许多现有的解决方案 – KingCrunch
'[A-。 Za-z0-9_]' - >'\ w'。 – alex
http://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses –