i found this regular expression :
"^(([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+)*$"
which validates a list of email like : [email protected];[email protected]
But i need to tweak it to validate in fact this sturcture :
[email protected];[email protected];
and also just one email address with this structure :
[email protected];
I also want to be able to validate email addresses containing + sign ,
for example validating :
address1@gmail;[email protected];[email protected];
as a valid list of emails.
Thank you for your help.
do not abuse regular expression too much.
it's not worthy to spend a lot of time and effort writing something inefficient and hard to analyze.
if you know it's semicolon separated, i would provid following pseudocode:
the regular expression
[\w\-\.+]+@([\w+\-]+\.)+[a-zA-Z]{2,5}validates one email address. it's perl-compatible syntax.it matches a-zA-Z_-.+ in the domain, and allows domain names with a-zA-Z- in it, and end with 2 to 5 a-zA-Z combination.
in the regex you provided, it matches domain name with
([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5}){1,25})+, it's odd. i don't think you should do it this way.about the reason why i said you are abusing regex is that, even though the problem you want to solve can be solved in regex, but
it takes more than linear time to design and debug regex as it gets longer.
it takes more than linear time for long regex to execute.
it's hard for other people to understand what you attempt to do. it's kind of preventing people from modifying you code, if it's not what you want.
so, please, never try to solve problem like this using pure regex. it's not a programming language.