This is your original expression, changed so that it allows several emails separated by semicolon and (optionally) spaces besides the semicolon. It also allows a single email address that doesn't end in semicolon.
This allows blank entries (no email addresses). You can replace the final * by + to require at least one address.
(([a-zA-Z0-9_-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([a-zA-Z0-9-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)(s*;s*|s*$))*
If you need to allow comma, apart from semicolon, you can change this group:
(s*;s*|s*$)
by this one:
(s*(;|,)s*|s*$)
Important note: as states in the comment by Martin, if there are additional text before or after the correct email address list, the validation will not fail. So it would work as an "email searcher". To make it work as a validator you need to add ^
at the beginning of the regex, and $
at the end. This will ensure that the expression matches all the text. So the full regex would be:
^(([a-zA-Z0-9_-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([a-zA-Z0-9-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)(s*;s*|s*$))*$
You can add an extra s*
after the ^
to tolerate blanks at the beginning of the list, like this. I.e. include ^s*
instead of simply ^
The expression already tolerates blanks at the end as is.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…