Page 1 of 1

regex for a set of html buttons...

Posted: Thu Oct 06, 2005 8:23 am
by ska
Hello. I'm back with another Regex query. I'm getting better at these, but this isn't working yet...

I need to find a set of buttons which are displayed underneath each entry of a product on a page (DB driven). I need to pick these buttons up and move them to another place on that product's entry.

An example of the code I need to pick up:

Code: Select all

<a href="javascript:void(window.open('http://www.domainname.com/cgi-bin/full.pl?&sel1&&HOT1000192','','width=690,height=550,scrollbars=yes,resizable=yes'))"><img src="/images/product_details.gif" width="120" height="18" border="0" /></a>
<a href="javascript:void(window.open('http://www.multimap.com/p/browse.cgi?pc=GU46 6JJ','','width=665, height=480,scrollbars=yes,resizable=yes'))" ><img src="/images/local-map.gif" width="120" height="18" border="0" /></a> <a href="javascript:void(window.open('http://www.domainname.com/cgi-bin/plan.pl?hso&sel1&http://www.domainname.com/sel1/&HOT1000192','','width=690,height=550,scrollbars=yes,resizable=yes'))" ><img src="/images/plans.gif" width="120" height="18" border="0" /></a> 

</font>
The number of buttons can vary, but the beginning and ending of this section of code will always be the same. Also, the product code ('HOT****') varies, so I have to extract this and use in the regex (I have this already). And of course, the postcode is different, but I don't care what this is for each one. So what I have is:

Code: Select all

preg_match_all ("/<a href=".'"'."javascript:void(window.open('http:\/\/www. domainname.com\/cgi-bin\/full.pl?&".$agentcode."&&".$matches[0][$i]."','','width=690,height=550,scrollbars=yes,resizable=yes'))".'"><img src="\/images\/product_details.gif" width="120" height="18" border="0" \/><\/a>
<a href="javascript:void(window.open('."'http:\/\/www.multimap.com\/p\/browse.cgi?pc=.*','','width=665, height=480,scrollbars=yes,resizable=yes'))".'" ><img.*<\/font>/Uis', $result, $matchesBUTTONS);
Then once I have this in my array, I will be able to read it back out onto the page in another place...

Any ideas? At the moment the above regex doesn't produce any results. THanks.