in reply to Re: Question on Regular Expression
in thread Question on Regular Expression
FWIW, here's another variation. It has the advantage of producing empty strings rather than undefined values for absent pattern elements, so no need for a conversion step. It also has the advantage, if such it be, of not using named captures with the possible overhead of tied-hashery. It passes all tests above.
$string =~ m{ \A ([[:alnum:]]+?) (?= (?: \d+ [[:upper:]]{0,2})? \z) (\d*) ([[:upper:]]?) ([[:upper:]]?) \z }xms;
Give a man a fish: <%-(-(-(-<
|
|---|