cod*_*dex -3 php regex preg-match
我想从电子邮件中删除 + 符号,请帮助我编写一个不接受电子邮件中 + 符号的正则表达式。
abc@xyz.com - valid email
abc123@xyz.com - valid email
abc.def@xyz.com - valid email
abc+123@xyz.com - Invalid email
Run Code Online (Sandbox Code Playgroud)
根据我的评论,你可能会使用
^[^@+]+@\S+$
# start of line, anything not + or @ 1+ times, followed by @,
# not whitespaces and the end of the string
Run Code Online (Sandbox Code Playgroud)
使用 eg~作为分隔符并在 regex101.com 上查看演示- 问题是:为什么?+是完全有效的。