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

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -