/** Regular matching keyword highlighting
Keyword is the key word that needs to be highlighted.
Options:nsregularexpressioncaseinsensitive is case insensitive
*/
nsmutableattributedstring* newstring = [[Nsmutableattributedstring alloc] initWithString:model.totalstring];
Nsregularexpression *regex = [[Nsregularexpression alloc]initwithpattern:[nsstring stringWithFormat:@ "%@", KeyWord] Options:nsregularexpressioncaseinsensitive Error:nil];
[Regex enumerateMatchesInString:model.totalstring options:nsmatchingreportprogress range:nsmakerange (0, Model.totalstring length]) usingblock:^ (Nstextcheckingresult *result, nsmatchingflags flags, BOOL *stop) {
[NewString AddAttribute: (nsstring*) Nsforegroundcolorattributename
Value: (ID) [Uicolor redcolor]
Range:result.range];
} ];
The second method
// Nsrange range = [[content lowercasestring] rangeofstring:[specialstr lowercasestring]];
// nsmutableattributedstring *attribute = [[Nsmutableattributedstring alloc] initWithString: Content];
// [attribute Addattribute:nsforegroundcolorattributename Value:[uicolor blue] range:range];
// return attribute;