We have a textbox which accepts comma separated email address. The regular expression is
^(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\s*[,]?\b)*$.
However now I am unable to add a length validation to this expression. Each email address should not be more than 150 characters. I have tried
^((\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)){1,150}\s*[,]?\b)*$.
But it doesn’t work.
Can you please modify the regex so that it also implements this validation too.
I would rather not complicate this regex further and add explicit length check before checking that e-mail matches. In JavaScript it will be something like the following:
By the way, dot after
$in your regex seems to be a mistake, so I skipped it in my snippet.