Regex for checking if a string is strictly alphanumeric
How can I check if a string contains only numbers and alphabets ie. is alphanumeric? Raghav Considering you want to check for ASCII Alphanumeric characters, Try this: "^[a-zA-Z0-9]*$" . Use this RegEx in String.matches(Regex) , it will return true if the string is alphanumeric, else it will return false. public boolean isAlphaNumeric(String s){ String pattern= "^[a-zA-Z0-9]*$"; return s.matches(pattern); } If it will help, read this for more details about regex: http://www.vogella.com/articles/JavaRegularExpressions/article.html In order to be unicode compatible: ^[\pL\pN]+$ where \pL stands