Say I have this:
<li class="one"><strong>String here: </strong><span class="one">
<!--googleoff: all-->
<strong>STRING TO GRAB</strong>
<!--googleon: all-->
</span></li>
How can I grab the STRING TO GRAB efficiently with RegEx? Keep in mind that this isn’t the only text on the page, so /<strong>(.*)<\/strong>/ wouldn’t work.
Thanks
There are two ways.
Dom classes: use the dom classes of PHP if the html is sort of a decent kind.
See:
– http://www.php.net/manual/en/domxpath.query.php
– http://www.php.net/manual/en/domdocument.loadhtml.php
Regex
If it’s not really valid html or dom loading does not work, perhaps regex is a good solution.
I’m assuming that the <!–googleoff: all–> is always present, this might work, if not, perhaps you can supply some more comments on the specificity of the string:
Final tip
To test the regex further: http://tinyurl.com/6gy6584