How to match all numerical characters and some single characters using regex
问题 How can I match all numbers along with specific characters in a String using regex? I have this so far if (!s.matches("[0-9]+")) return false; I don't understand much regex, but this matches all characters from 0-9 and now I need to be able to match other specific characters, for example "/", ":", "$" 回答1: You can use this regex by including those symbols in a character class : s.matches("[0-9$/:]+") Read more about character class 回答2: You can add the other characters that you need to match