how can i create a preg_match_all regex pattern for php to give me this code?
<td class="class2"> </td>
<td class="class2" align="right"><span class="DarkText">I WANT THIS TEXT</span></td>
To get me the text inside the span class? thanks!
how can i create a preg_match_all regex pattern for php to give me this code?
<td class="class2"> </td>
<td class="class2" align="right"><span class="DarkText">I WANT THIS TEXT</span></td>
To get me the text inside the span class? thanks!
You can use:
preg_match_all("!<span[^>]+>(.*?)</span>!", $str, $matches);
Then your text will be inside the first capture group (as seen on rubular)
With that out of the way, note that regex shouldn't be used to parse HTML. You will be better off using an XML parser, unless it's something really, really simple.
It's tough to write Regexes that parse HTML perfectly. Instead, use an HTML parser like this one: http://simplehtmldom.sourceforge.net/. It is easy to use and I have recommended it on here several times.