regex - Matching everything between html <body> tags using PHP -
I have a script that gives the following in variable named $ content
& Lt; Body & gt; & Lt; P & gt; & Lt; Span class = \ "c-sc \" & gt; Dgdfgdf & lt; / Span & gt; & Lt; / P & gt; & Lt; / Body & gt;
I have to match all the places in the middle of the byte tag by the name of the match
I do the following to match the content between body tags
preg_match ('/ / LT; body & gt; (*). ; /', $ content matches $ $);
But the $ mathces array is empty, how can I return it to everything inside the body tag
You should not use regular expressions to parse HTML.
In this case, you have to add your special problem so that the dot newline can be prepared.
preg_match ('/ & lt; body & gt; (. *) & Lt; / body & gt; / s', $ content, $ matches);
But seriously, use an HTML parser instead. There are several ways that can break the above mentioned regular expression.
Comments
Post a Comment