Sonarqube is warning me that my Java regex reported down below for email validation should be refactored because "this repetition can lead to a stack overflow for large inputs":
"^(?=.{1,64}@)[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$"
Plus, they're emphasizing on this part in particular:
(\\.[A-Za-z0-9-]+)*
It works perfectly fine in my program, it accepts emails with this kind of format:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Still, I would like to fix this issue.
I am not able to understand what I should do to fix it tho, is there a way to modify this regex while keeping the same meaning?