Page 1 of 1

dummy help

Posted: Mon Dec 08, 2008 9:34 pm
by yshaf13
This is probably a no brainer for you guys but i just can't wrap my head around the whole regex thing... I'm parsing an html document and i need to extract content between two tags so if i have in the page <b class="CPprodDescDet">lorem ipsum</b> it should just return "lorem ipsum".
this is what i have so far, but it's returning the whole thing (<b class...):
/^<b class="CPprodDescDet"> .*? <\/b>$/

what am i doing wrong?

is there a better way to do it?

Re: dummy help

Posted: Mon Dec 08, 2008 9:41 pm
by Syntac
Try this:

Code: Select all

$text = preg_replace("#<b class=\"CPprodDescDet\">(.*?)</b>#is", "$1", $the_string);

Re: dummy help

Posted: Tue Dec 09, 2008 12:52 am
by yshaf13
that works great, thanks alot.