Last active
August 29, 2015 14:07
-
-
Save hilburn/62503d7e1a628c6b3f62 to your computer and use it in GitHub Desktop.
containsWord
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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