preg_match_all problems

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
aff_dan
Forum Newbie
Posts: 1
Joined: Wed Aug 24, 2005 12:29 am

preg_match_all problems

Post by aff_dan »

Hi Sirs,
I have this PHP code:

Code: Select all

// Output 
$s = $source->getSource(); 

if (preg_match_all('{<td><font face="verdana,sans-serif" size=(1¦2)\s?(color=E8E8E8)?>&nbsp;?([0-9]+?)</td>\n<td>(&nbsp;<a href="(.+?)">)?<font face="verdana,sans-serif" size=(1¦2) color=(#000000¦E8E8E8)>(&nbsp;)?(.+?)</a></td>}is', $s, $out, PREG_SET_ORDER)) { 

for($i=0;$i<count($out);$i++) { 
array_push($keywords, $out[$i][3].'~'.$out[$i][9]); 
}
using this PHP code to copy from an HTML source:

Code: Select all

<td><font face="verdana,sans-serif" size=1>&nbsp;53021</td> 
<td>&nbsp;<a href="?article=free&mkt=us"><font face="verdana,sans-serif" size=1 color=#000000>free</a></td> 
</tr>
My PHP code is wrong? Where is the wrong in my php code?

Please help

Regards,
Dan
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

first thing that jumps out is your pattern being invalid. You have the pattern enclosed in {}, whereas a pattern must be enclosed in the same exact symbols on both ends.
Post Reply