Popcorn Dave has asked for the wisdom of the Perl Monks concerning the following question:
Fellow monks,
To disagree, one doesn't have to be disagreeable - Barry Goldwater
I was surfing around Yahoo Answers the other day and a person was asking for an explanation of what the following regex did:
s/^\[[0-9]{2}-[0-9]-{2}-([0-9]{2} | [0-9] {2, 4})\]\s+//;
Of course I pointed him towards YAPE::Regex and presented him with the explanation output, but what struck me as odd was the
([0-9]{2} | [0-9] {2, 4})
Unless I'm mistaken, you're matching 2 numbers or between 2 and 4 numbers. Why would use the | there? If you're matching between 2 and 4 numbers you're matching 2 already aren't you? Am I just missing something here?
To disagree, one doesn't have to be disagreeable - Barry Goldwater
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Redundant regex ([0-9]{2} | [0-9] {2, 4})?
by ikegami (Patriarch) on Feb 26, 2009 at 22:42 UTC | |
by Popcorn Dave (Abbot) on Feb 27, 2009 at 00:34 UTC | |
by ikegami (Patriarch) on Feb 27, 2009 at 01:35 UTC |
Back to
Seekers of Perl Wisdom