After a quick research on the Stackoverflow, I wasn't able to find any solution for the multiple email validation using regex (split JS function is not applicable, but some reason back-end of the application waits for a string with emails separated by ;).
Here are the requirements:
- Emails should be validated using the following rule:
[A-Za-z0-9\._%-]+@[A-Za-z0-9\.-]+\.[A-Za-z]{2,4} - Regex should accept
;sign as a separator - Emails can be written on multiple lines, finishing with
; - Regex may accept the end of the line as
;
I come up with this solution:
^[A-Za-z0-9\._%-]+@[A-Za-z0-9\.-]+\.[A-Za-z]{2,4}(?:[;][A-Za-z0-9\._%-]+@[A-Za-z0-9\.-]+\.[A-Za-z]{2,4}?)*
but it doesn't work for point #3-4
So here are cases that are OK:
1. john@smith.com;john@smith.com
2. john@smith.com;john@smith.com;
3. john@smith.com;
john@smith.com;
jjoh@smith.com;
Here are cases that are definetely NOT OK:
1. john@smith.com jackob@smith.com
2. jackob@smith.com,
3. daniels@mail.com
smth@mail.com
All sort of help will be appreciated