Page 1 of 1

help! regular expressions :(

Posted: Wed Dec 22, 2004 1:19 pm
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.. :)

Posted: Wed Dec 22, 2004 1:29 pm
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 ?

Posted: Wed Dec 22, 2004 1:37 pm
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>.........

Posted: Wed Dec 22, 2004 1:41 pm
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?"

Posted: Wed Dec 22, 2004 2:02 pm
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.