iphone - Safe to use Regex for this? (HTML) -


i'm parsing html, , need html in body tag. target string this:

<body><div><img src="" />text etc</div></body> 

however, need:

<div><img src="" />text etc</div> 

my target string begin , end body tags. however, there repeated warning of not use regex parse html, not have viable solutions available, besides regex @ moment.

question: there safe regex(s) use in case? or should forget it?

you didn't show regex is, it's not safe using dom parsing if it's simple as:

<body>(.*?)</body> 

...because it's possible </body> contained in attribute string or comment. if you're willing take risk, you'll fine. there's no reason shouldn't able use dom parsing , text of body, though, except less efficient.

you skip regex , find string indices of <body> , </body> , substring between them. should faster.

by way, not parsing html; you're extracting html


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -