Stuck with a pattern...

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

Moderator: General Moderators

Post Reply
welsh_sponger
Forum Newbie
Posts: 14
Joined: Fri Feb 03, 2006 7:46 am

Stuck with a pattern...

Post by welsh_sponger »

I need to match from this html

$html = ...<td>&nbsp; &nbsp; &nbsp; 04:04 <span class="redtext"> 2.09m</span></td>...

the value 2.09 in two matches, 2 then 09

my pattern so far...

Code: Select all

preg_match( "#\s+(\w{2})\:(\w{2})\s+[\<](\w{4}\s\w{5}[\=\w{9}\>\s+])#im", $html, $match);
which works up to the end of the "redtext"> part but cannot match the values I want from here, tried lots but cant work it out. Also i thought about trying the match from "redtext"> straight off, but its the second occurence of this.

If anyone could tell me what i need to add to my current code that would be extremly helpful.

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

Post by feyd »

Code: Select all

#<\s*td[^<>]*>(?:&nbsp;|\s)*\d{2}:\d{2}(?:&nbsp;|\s)*<\s*[a-z]+\s+[^<>]*?redtext[^<>]*>\s*(\d (\.\d )?\s*[a-z])#s
:?:
Post Reply