iphone - NSRegularExpression for stripping HTML Tag -
i developing ebook reader app. have .epub file entire ebook in each topic of ebook html file. want implement search functionality in app. using nsregularexpression class searching. please consider following html code:
<temp> temp in tempo temptation </temp>
say example in above html code want search word temp. in above code temp appearing 5 times -> <temp> </temp>
temp tempo temptation. looking regular expression can extract whole word "temp". don't want consider word temp in html tags <temp> </temp>
. don't want word tempo , temptation considered.
thanks in advance
how this?
[^<\/?\w*>]+(temp\s)
http://rubular.com/r/3pkdvnzsbr
nsstring *evaluate_string = @"<temp> temp in tempo temptation </temp>"; nsstring *word = @"temp"; nserror *outerror; nsregularexpression *regex = [nsregularexpression regularexpressionwithpattern:[nsstring stringwithformat:@"[^<\\/?\\w*>]+(%@\\s)", word] options:0 error:&outerror]; nstextcheckingresult *result = [regex firstmatchinstring:evaluate_string options:0 range:nsmakerange(0, [evaluate_string length])]; if(result) { nslog(@"found"); }
Comments
Post a Comment