[英]Avoiding 2 '@' signs in email address when using \P{M} within regular expression
I'm creating a validation regular expression for email addresses, the problem is that not only standard Latin chars are accepted but also Russian, Swedish and other languages that uses non Latin characters. 我正在为电子邮件地址创建一个验证正则表达式,问题是不仅接受标准的拉丁字符,而且还接受俄语,瑞典语和其他使用非拉丁字符的语言。
what i am using is the \\P{M}
code, which basically allows the insertion of any Unicode codepoint. 我正在使用的是
\\P{M}
代码,该代码基本上允许插入任何Unicode代码点。 The problem is..... i off course want only 1 '@' (at) allowed, as according to standard syntax for email addresses. 问题是.....按照电子邮件地址的标准语法,我当然只希望允许1个'@'(@)。 How can i avoid that?
我如何避免这种情况? This is the RegEx i have so far:
这是我到目前为止拥有的RegEx:
input.matches("\\P{M}+@{1}\\P{M}+\\.[a-zA-Z]{2,6}$");
Thx for any advice, i have been trying with a lot of different combinations but nothing so far 谢谢任何建议,我一直在尝试许多不同的组合,但到目前为止没有任何帮助
Thank you 谢谢
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.