I am trying the validate email with the following regex pattern,
@Pattern(regexp="^$|[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}\\@[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}(\\.[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25})+", message = "Email address invalid")
This regex works as expected, but Sonar highlights it to be critical bug:
Refactor this repetition that can lead to a stack overflow for large inputs.
Can you please help in shortening the regex, but logic should still remain same?
