Skip to content

Instantly share code, notes, and snippets.

@hilburn
Last active August 29, 2015 14:07
Show Gist options
  • Save hilburn/62503d7e1a628c6b3f62 to your computer and use it in GitHub Desktop.
Save hilburn/62503d7e1a628c6b3f62 to your computer and use it in GitHub Desktop.
containsWord
public static boolean containsWord(String s, String word) {
Pattern pattern = Pattern.compile("\\s"+word+"[\\s]|\\s"+word+"$|^"+word+"\\s|^"+word+"$");
Matcher matcher = pattern.matcher(s);
return matcher.find();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment