in reply to Re: pattern matching
in thread pattern matching

Curious. You restrict yourself to the Western, unaccented, letters (ASCII), but you allow hundreds of different digits.

I would have used either

/[A-Z]{2,5}[0-9]{5}/ # Ascii ranges
or
/\p{Lu}{2,5}\p{Nd}{5}/ # Full Unicode set

Replies are listed 'Best First'.
Re^3: pattern matching
by Porculus (Hermit) on Apr 10, 2009 at 13:15 UTC

    Premature generalisation is the root of much evil.

    In practice, since the OP did not mention any character-set complications, it is a reasonable assumption that the task in question does not require matching non-ASCII capital letters or require excluding non-ASCII numerals. So there is no need to worry about Unicode ranges, and distinguishing between \d and [0-9] is splitting hairs.

      In this age and time, and the fact that Perl has escaped outside of the US border, not assuming someone means "ASCII" when talking about letters or digits isn't "premature generalisation". It's not that [A-Z] is such a savings on keystrokes over \p{Lu}.

      At least you could have mentioned your odd choice (assuming you actually thought about any "character-set complications").