On Jan 26, 2008 11:29 AM, Jerald Sheets <[EMAIL PROTECTED]> wrote:
> Note that on that particular kind of feed, you *can* have three digits
> on occasion.
>
> How would you go about allowing for the third digit if and only if it
> exists?
>
> I had the first regex, but I'm not sure where the allowance for the
> third digit would come in, or how to allow for a random series of
> digits that can contain two or three at any given time.
snip

A third digit in the hour would be an error and the temperature
capture is everything between the first two commas, where is this
third digit you are worried about?  If you do need to capture/match
two or three instances of a pattern use the quantifier:
/^(?:pattern){2,3}$/ matches "patternpattern" or
"patternpatternpattern".  If you have an optional pattern you can use
the ? (or {0,1}) quantifier: /^xy?$/ matches "x" or "xy".  See perldoc
perlre or http://perldoc.perl.org/perlre.html#Regular-Expressions for
more information.


snip
> Note:  I mean my little jab to go privately for fun.  I didn't mean to
> come off sounding quite so douchey.  Apologies all around.
snip

Don't worry about how you sound, worry about top-posting instead.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to