i want to check for a string that only contains alphanumerics and few special chars which are:
1) dash
2) space
3) dot
with size 3-255 characters only.
but my below expression doesnt seems to work..something is wrong with the size i think..
@Pattern(regexp = "^[-a-zA-Z\s\.]{3,255}+$"
i even tried this:
@Pattern(regexp = "^[-a-zA-Z\s\.]\w{2,256}+$"
but that raises issue to the size validation due to the \w char – because it will only accepts alphanumeric and not special chars i guess…
any idea??
dash is special key too. add backslash. And you don’t need + to the end.