I'm trying to validate a String
with this format (4 letters and 10 digits):
ABCD1234567890
But this code isn't working
@NotNull(message="tarjeta sanitaria cannot be null")
@Pattern(regexp = "(([A-Z]){4})([0-9]){10}",message = "tarjeta sanitaria is not valid")
private String tarjSanitaria;
Any idea?
I think that you miss start and end of the string in your pattern.
Maybe this is what you are looking for:
^[A-Z]{4}[0-9]{10}$
You can test your regex using this page https://regex101.com/