I'm new to regular expressions and I would appreciate some help. if the original code is something like: here is html code <font face="times new roman" size="+2"><B>Some Name Here</b></font> more html code HTML: and I want to extract just: Some Name Here I started with this code but it doesn't work: preg_match("<%font%[^>]*>(.*?)</%font%>", $pagecontent,$matches); PHP:
function GSB($oString, $oStart, $oEnd, $start = 1) { $strings = explode($oStart, $oString); $tempstr = $strings[$start]; $strings = explode($oEnd, $tempstr); return $strings[0]; } PHP: GetStringBetween function, written by me. For your example, you would want to use this: <?php function GSB($oString, $oStart, $oEnd, $start = 1) { $strings = explode($oStart, $oString); $tempstr = $strings[$start]; $strings = explode($oEnd, $tempstr); return $strings[0]; } $html = "<font face=\"times new roman\" size=\"+2\"><B>Some Name Here</b></font>"; $strName = GSB($html, 'size="+2"><B>', '</b></font>'); echo $strName; ?> PHP: This would output 'Some Name Here'
preg_match("/<font face="times new roman" size="\+2"><B>(.*)<\/b><\/font>/U", $pagecontent,$matches); Code (markup): Should work. Peace,