简体   繁体   中英

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. The problem is..... i off course want only 1 '@' (at) allowed, as according to standard syntax for email addresses. How can i avoid that? This is the RegEx i have so far:

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM