I need to perform a keyword search in a string that exact match.
EmailTemplate et = [SELECT Id htmlValue FROM EmailTemplate where Name = 'Welcome Email'];
string htmlValue = et.htmlValue;
string s1 = 'Hello there {!Contact.Name},';
string s2 = 'Did you know {!Contact.Deal} this is a test?';
static Boolean keywordSearch(String input, String keywordPhrase)
{
return Pattern.compile('(?i)\\b' + keywordPhrase + '\\b').matcher(input).find();
}
system.assert(keywordSearch(htmlValue, s1));
I want to match exact like word to word except the case sensitive, I have tried using contains
or equals
but that does not work word to word, if I skip ?
which is in string s2
and use contains
it does pass the assert which is suppose to get failed