java - Check that the input only contains certain characters -
i need check input string contains alphabetic characters, asterisks, spaces, , tabs.
i tried this, doesn't work:
firststr.matches(".*[a-za-z].*.*[\\t].*.*[\\s].*")
use regex check if string contains alphabets, spaces, asterisks, tabs:
firststr.matches("[a-za-z *\t]+") you close, needed single character class.
Comments
Post a Comment