简体   繁体   English

在正则表达式中使用\\ P {M}时,避免在电子邮件地址中使用2个“ @”符号

[英]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])+)\])

http://www.regular-expressions.info/email.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java email 使用正则表达式验证地址 - Java email address validation using regular expression 使用带有posix语法的正则表达式来验证电子邮件地址 - Using a regular expression with posix syntax to validate an email address 如何使用正则表达式删除电子邮件地址中的点(。)字符 - How to remove dot (.) character in email address using regular Expression 正则表达式:电子邮件地址中的多个子域 - Regular expression: multiple subdomain in email address 使用特殊的电子邮件正则表达式 - Using a special email regular expression 如何使用selenium web驱动程序从跨区文本中提取不是正则表达式格式的电子邮件地址? - How to extract an email address which is not in a regular expression format from a span text using selenium web driver? 正则表达式,如何分割|并且在\之前避免分裂 - Regular Expression, how to split with | and avoiding to split when \ is before 验证以 .services 结尾的电子邮件地址的 Java 正则表达式 - Java regular expression to validate email address that end with .services 带有 \\\\p{Ll} 的正则表达式 - Regular expression with \\p{Ll} 为什么在我写replaceAll(“\\p{P}”,“”)时删除“\n”,因为“\\p{P}”只是PUNCTATION的正则表达式 - why is "\n" removed when I write replaceAll("\\p{P}", ""), because "\\p{P}" is a regular expression for PUNCTATION only
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM