I'm having trouble bolding any characters between an indicated pair of "**" characters. For example, in this NSString:
"The Fox has ran **around** the corner."
should read: "The fox has ran around the corner"
here is my code :
NSString *questionString = queryString;
NSMutableAttributedString *mutableAttributedString = [[NSMutableAttributedString alloc] initWithString:questionString];
NSRange range = [questionString rangeOfString:@"\\*([^**]+)\\*" options:NSRegularExpressionSearch|NSCaseInsensitiveSearch];
if (range.location != NSNotFound) {
[mutableAttributedString setAttributes:@{NSFontAttributeName:[UIFont fontWithName:AGHeavyFontName size:size]} range:range];
}
[[mutableAttributedString mutableString] replaceOccurrencesOfString:@"*" withString:@"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, queryString.length)];
return mutableAttributedString;
I'm having issues- this code will still catch characters with one pair of "*"'s, so in this case,
"The fox has ran *around the corner*
will still read as "The fox has ran around the corner", when it shouldnt.
Any ideas?