help! regular expressions :(

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brownguy02
Forum Newbie
Posts: 3
Joined: Wed Dec 22, 2004 1:02 pm
Location: Trenton, ND

help! regular expressions :(

Post by brownguy02 »

I am Noel King; 21 years old. 1 year ago I had a stroke :(. So.. Typo/Grammer sucks.. sorry :D

i try regular expressions i cant working.. $fdate -> "Dec 21"...
tomorrow $fdate -> "Dec 22" so..

$fdate = dynamically
$test = string
$matches = match

Code: Select all

ereg("$fdate", $test, $matches);
help ..thank you!

ps. 1 year from now maybe 100% speech/grammer good.. :)
Last edited by brownguy02 on Wed Dec 22, 2004 1:57 pm, edited 1 time in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

I'm not too sure what you're after.
Can you provide an example of what you will be passing in and what you want to match against?
i.e Examples of what $fdate and $test might be ?
brownguy02
Forum Newbie
Posts: 3
Joined: Wed Dec 22, 2004 1:02 pm
Location: Trenton, ND

Post by brownguy02 »

Code: Select all

ereg($fDate, $test, $matches);
$fDate = Date(M,d); //dynamically
$Matches -> Array
$test ->

Code: Select all

............<TR>
<TD WIDTH="15%">Tonight|Today|<BR> Dec 21</TD>
<TD WIDTH="10%"><IMG SRC="http://image.weather.com/web/common/wxicons/31/29.gif" WIDTH=31 HEIGHT=31 BORDER=0></TD>
<TD WIDTH="35%">Partly Cloudy</TD>
<TD WIDTH="25%" ALIGN="CENTER"><B>-5°</B></TD>
<TD WIDTH="15%" ALIGN="CENTER">0 %</TD>
</TR>
      
<TR>
<TD CLASS=f2a><FONT CLASS="blkVerdanaText10">Wed <BR> Dec 22</FONT></TD>
<TD CLASS=f2a><IMG SRC="http://image.weather.com/web/common/wxicons/31/13.gif" WIDTH=31 HEIGHT=31 BORDER=0></TD>
<TD CLASS=f2a><FONT CLASS="blkVerdanaText10">Scattered Flurries</FONT></TD>
<TD CLASS=f2a ALIGN="CENTER"><FONT CLASS="blkVerdanaText10"><B>7°/-12°</B></FONT></TD>
<TD CLASS=f2a ALIGN="CENTER"><FONT CLASS="blkVerdanaText10">20 %</FONT></TD>
</TR>
      
<TR>
<TD ><FONT CLASS="blkVerdanaText10">Thu <BR> Dec 23</FONT></TD>
<TD ><IMG SRC="http://image.weather.com/web/common/wxicons/31/30.gif" WIDTH=31 HEIGHT=31 BORDER=0></TD>
<TD ><FONT CLASS="blkVerdanaText10">Partly Cloudy</FONT></TD>
<TD  ALIGN="CENTER"><FONT CLASS="blkVerdanaText10"><B>4°/-6°</B></FONT></TD>
<TD  ALIGN="CENTER"><FONT CLASS="blkVerdanaText10">0 %</FONT></TD>
</TR>
      
<TR>
<TD CLASS=f2a><FONT CLASS="blkVerdanaText10">Fri <BR> Dec 24</FONT></TD>
<TD CLASS=f2a><IMG SRC="http://image.weather.com/web/common/wxicons/31/14.gif" WIDTH=31 HEIGHT=31 BORDER=0></TD>
<TD CLASS=f2a><FONT CLASS="blkVerdanaText10">Snow Shower</FONT></TD>
<TD CLASS=f2a ALIGN="CENTER"><FONT CLASS="blkVerdanaText10"><B>28°/19°</B></FONT></TD>
<TD CLASS=f2a ALIGN="CENTER"><FONT CLASS="blkVerdanaText10">30 %</FONT></TD>
</TR>.........
brownguy02
Forum Newbie
Posts: 3
Joined: Wed Dec 22, 2004 1:02 pm
Location: Trenton, ND

Post by brownguy02 »

brownguy02 wrote: $fDate = Date(M,d); //dynamically
i use "dec 22" and "Partly Cloudy"
tomorrow
i will use "dec 23" and "i dont know.. snow? sunny?"
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

That's beyond my limited regex skills but you might want to take a look at http://pear.php.net/package/Services_Weather instead. It will be easier to use the weather services provided by weather.com rather than parse their html output.
Post Reply