字符串搜索

在一個字符串A中搜索特定字符串Bspa

 NSInteger locationBegin = 0;//開始搜索字符串A字符串

                            do {it

                                NSRange range = [A rangeOfString:B options:NSCaseInsensitiveSearch range:NSMakeRange(locationBegin, A.length - locationBegin)];io

                                if (range.length > 0) {搜索

                                 //這裏就能夠拿到range了  設置一個數據保存就能夠 或者 作其餘操做 好比替換成Cim

                                    [A replaceCharactersInRange:range withString:C];數據

                                    locationBegin += range.length + range.location;img

                                }else{while

                                    break;字符

                                }

                            } while (locationBegin + imgStr.length <= A.length);

相關文章
相關標籤/搜索