Re: What's the regex for this...?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brian Dunning wrote:
I have the source of a web page stored in $here and I want to set $this to whatever appears between '<span class="myclass">' and '</span>'. Example:

$here contains (amid tons of other stuff): <span class="myclass">This is a statement.</span>

I want to set $this to "This is a statement."

What code do you have so far?

if it's strictly between those tags, this should work:

preg_match_all('%<span class="myclass">(.*?)</span>%isU', $text, $matches);

$matches[1] will be an array with all matches.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux