写在开头
在开发过程中,遇到的一些算法问题,写在这里记录一下
一、高亮规定字符串
//搜索匹配算法
//高亮<em></em>中间的字符串
//NSString *aString = @"I am a <em>string</em>, not a a<em>string</em>, just a <em>string</em>";
- (NSMutableAttributedString *)newSetSearchResultStringColor:(NSString *)importString {
NSMutableAttributedString *resultString = [[NSMutableAttributedString alloc] initWithString:importString];
NSString *subString_1 = @"<em>";
NSString *subString_2 = @"</em>";
//获取subString_1的下标位置
NSArray *subString_1_array=[importString componentsSeparatedByString:subString_1];
NSMutableArray *arrayOfLocation1 = [NSMutableArray array];
int d = 0;
for (int i = 0; i < subString_1_array.count - 1; i++) {
NSS