ios - Regex for html string in Objective C -
i getting html formatted string tags. there inconstancy "<br>" tag. getting"<br>" tag in random formats causes space in text. there solution trim these multiple "<br>" tags single one?
example of text :-
"some text..... <br>" "some text..... <br> <br>" // <-- cause space. "some text..... <br>\n" // <-- cause space. "some text..... <br>\n<br>" // <-- cause space. "some text..... <br><br>\n <br>" // <-- cause space. so in short, there can multiple "<br>" tags white spaces , \n character in it.
i need replace single "<br>" tag. can me regex same?
note:- don't want replace other string in between 2 "<br>" tags except white space , "\n" .
code written till -
nsmutablestring *temp = [[nsmutablestring alloc] initwithstring:html]; [temp replaceoccurrencesofstring:@"<br><br>" withstring:@"<br>" options:0 range:nsmakerange(0, [temp length])]; [temp replaceoccurrencesofstring:@"<br>\n<br>" withstring:@"<br>" options:0 range:nsmakerange(0, [temp length])]; [temp replaceoccurrencesofstring:@"<br>\n" withstring:@"<br>" options:0 range:nsmakerange(0, [temp length])]; it's static string, needed regex it.
find: (<br>)(\s*\1)+ replace: $1
Comments
Post a Comment