java - validating a string with RegEx -
i trying validate regex string in java cant work properly. attempting make sure the following string "ab10xy" contained textfield when performing search.
i have following line of code ensures ab , xy in textfield not number:
boolean checkchar = ((textfield.gettext().contains("ab")) && (textfield.gettext().contains("xy"))); i prefer have :
boolean checkchar = ((textfield.gettext().contains("ab[\\d]{2}xy")));
you can try way
boolean checkchar = ((textfield.gettext().matches(".*?ab[\\d]{2}xy.*")));
Comments
Post a Comment