nsstring - NSRegularExpression (iOS) -
a have little problem parsing html string. have big string , need delete characters between "script" tag. :
<script...>some text here</script>
so need delete "some text here". think great use nsregularexpression. can me ? lot.
while advised not parse html regular expressions (see my all-time favorite s.o. answer), can approximate like:
nsregularexpression *regex = [nsregularexpression regularexpressionwithpattern:@"<script.*?>(.*?)</script>" options:nsregularexpressioncaseinsensitive | nsregularexpressiondotmatcheslineseparators error:&error]; [regex enumeratematchesinstring:string options:0 range:nsmakerange(0, [string length]) usingblock:^(nstextcheckingresult *result, nsmatchingflags flags, bool *stop) { nslog(@"%@", [string substringwithrange:[result rangeatindex:1]]); }];
Comments
Post a Comment