java - Validating numeric sequence -
i using java , need validate numeric sequence this: 9999/9999.
i tried using regex \\d{4}\\\\d{4}, getting false matches().
my code:
pattern regex = pattern.compile("\\d{4}\\\\d{4}"); if (!regex.matcher(mysequence).matches()) { system.out.println("invalid"); } else { system.out.println("valid"); } can me, please?
the regex pattern attempting match backslash rather forward slash character. need use:
pattern regex = pattern.compile("\\d{4}/\\d{4}")
Comments
Post a Comment