[LA.pm] regex -ing numbers

David Heayn david at cloudgraphics.com
Mon Jul 4 21:41:07 PDT 2005


I'm trying to use regex again. This time I haven't a clue where to 
look. The program is for my personal weather home page. I need to 
compress lengthy descriptions into little bites that are still useful 
and then I use the space between forecasts to split out the current 
day and de-convert everything as an end step.

chunk I'm having problems with is below:


$conditionsVar = "T-storms 28% chance Chance of T-storms 30% chance 
Chance of T-storms 21% chance Partly Cloudy Partly Cloudy"  # this 
line doesn't really exist, it's just today's data.

$conditionsVar =~ s/Partly Cloudy/PCloudy/ig; # this line works
$conditionsVar =~ s/Chance of T-storms (\d{1,2})% 
chance/ChanceofT-storms($1)%chance/ig; #doesn't work
$conditionsVar =~ s/T-storms (\d{1,2})% 
chance/T-storms($1)%chance/ig; #doesn't work
$conditionsVar =~ s/Chance of T-storms/CoTStorms/ig;  #this line works


#and then, $conditionsVar produces this:

T-storms 28% chance CoTStorms 30% chance CoTStorms 21% chance PCloudy PCloudy

#$conditionsVar needs to read like the end; PCloudy




oh yes- happy 4th to all

David Heayn * http://www.cloudgraphics.com * 213/925.3283


More information about the Losangeles-pm mailing list