Re: Looking for regex
- From: chas.owens@xxxxxxxxx (Chas. Owens)
- Date: Sat, 26 Jan 2008 11:44:18 -0500
On Jan 26, 2008 11:29 AM, Jerald Sheets <questy@xxxxxxxxx> wrote:
Note that on that particular kind of feed, you *can* have three digitssnip
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.
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 tosnip
come off sounding quite so douchey. Apologies all around.
Don't worry about how you sound, worry about top-posting instead.
.
- References:
- Looking for regex
- From: John Kufrovich
- Re: Looking for regex
- From: Chas. Owens
- Re: Looking for regex
- From: Jerald Sheets
- Looking for regex
- Prev by Date: Re: Looking for regex
- Next by Date: Re: Last line issue
- Previous by thread: Re: Looking for regex
- Next by thread: Re: Looking for regex
- Index(es):