Below is my regex:
[^4\\d{3}-?\\d{4}-?\\d{4}-?\\d{4}$]
But it throws an error at -. I am using ?, which should al
-
?
Try escaping - with \ and remove [ and ]:
\
[
]
^4\d{3}\-?\d{4}\-?\d{4}\-?\d{4}$