Getting strange error in sonarqube for email validation. Can anyone help in shortening the regex, but logic should still remain same?

Viewed 24

I am trying to validate email in Java Spring boot dto. This regex works fine for me, but in sonarqube I'm getting this warning/error "refactor this repetition that can lead to a stack overflow for large inputs".

private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)@" + "[A-Za-z0-9-]+(\.[A-Za-z0-9]+)(\.[A-Za-z]{2,})$";

Can someone shorten the regex or provide me better solution to avoid this type of warning for my regex in sonarqube ? I'm attaching the screenshot of warning :

this error

0 Answers
Related