I'm having an issue finding multiple groups of substrings indicated by a pair of ** characters, and bolding them. 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:@"\\*{2}([^*]+)\\*{2}" options:NSRegularExpressionSearch];
if (range.location != NSNotFound) {
[mutableAttributedString setAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:size]} range:range];
}
[[mutableAttributedString mutableString] replaceOccurrencesOfString:@"**" withString:@"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, queryString.length)];
return mutableAttributedString;
this code only catches one pair of indicated characters, so all i get back is :The fox has ran around the corner
any ideas?