Skip to content

Instantly share code, notes, and snippets.

@vigneshrcsengg
Last active September 26, 2021 10:06
Show Gist options
  • Save vigneshrcsengg/9fdf4f294da2126f451d8a38b9449e98 to your computer and use it in GitHub Desktop.
Save vigneshrcsengg/9fdf4f294da2126f451d8a38b9449e98 to your computer and use it in GitHub Desktop.
String Utilities
class StringUtil {
public static void main(String args[]) {
}
public static boolean isOnlyOneWord(String s) {
return (s.length() > 0 && s.split("\\s+").length == 1);
}
public static boolean isStringContainNumeric(String str) {
return str.matches(".*\\d.*");
}
public static boolean isMatch(String text, String pattern) {
return text.matches(pattern.replace("?", ".?").replace("*", ".*?"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment