I am trying to build a regex pattern using the Pattern and Matcher classes in salesforce to find a exact match of a word . For eg. the word hot should be found in the 1st 3 string but not in the 4th one.
hot in here
how hot is it
[email protected] --- > should not match.
I tried with the below code but cannot get it to work. Any help is appreciated.
String strRegEx = '\\bhot\\b'; String str = ' how hot is it'; Pattern MyPattern = Pattern.compile(strRegEx); Matcher MyMatcher = MyPattern.matcher(str); Boolean result = MyMatcher.matches();