View Full Version : regex help

12-30-2006, 11:49 PM
On a page i have things like this:

<span id="ctl00_ctl00_content_PlayerAvatar_lblNickName">FIND THIS</span>

That is in the middle of tons of other stuff (its part of a webpage) and i want to find whatever is where "FINDTHIS" is on the page.

To explain better, what i want the code to do, is search through the source for that span line, and set a variable such as $nickname = "FIND THIS";

I know im not explaining this very well, but its the best I can do. If you have any questions dont hesitate to ask.

12-31-2006, 02:55 PM
try something like this:

preg_match('/<span id="ctl00_ctl00_content_PlayerAvatar_lblNickName">(.*?)<\/span>/s', $source, $nickname);
$nickname = $nickname[1];

01-01-2007, 12:58 AM
thanks that did it.