Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosiasSena/c257013bb222ad2430334468bd442ea1 to your computer and use it in GitHub Desktop.
Save JosiasSena/c257013bb222ad2430334468bd442ea1 to your computer and use it in GitHub Desktop.
Check if the string contains a number or a special character
/**
* Check if the string contains a number or a special character
*
* @param text - string to check
* @return - true if it contains a number or a special character, else false
*/
public boolean textContainsSpecialCharsOrNumbers(String text) {
return !text.matches("^[a-z A-Z]+$");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment