David Sheldon wrote:
=>
m/(^|\W)(([A-Za-z][0-9]|[A-Za-z][0-9]{2}|[A-Za-z][A-HJ-Ya-hj-y][0-9]|[A-Za-z][A-HJ-Ya-hj-y][0-9]{2}|[A-Za-z][0-9][A-Za-z]|[A-Za-z][A-HJ-Ya-hj-y][0-9][A-Za-z])\s+[0-9][ABD-HJLP-UW-Zabd-hjlp-uw-z]{2}|[Gg][iI][Rr]\W+0[aA]{2})(\W|$)/
I've no idea if the above is correct for the purposes
intended. But the regex itself can be simplified, making
it (more) readable and efficient.
\begin{untested-code}
|| m{
|| \b # Replaces $1 == (^|\W).
|| ([A-Za-z] [A-HJ-Ya-hj-y]? \d [A-Za-z0-9]? # Replaces 6 choices in $3.
|| \s+ \d [ABD-HJLP-UW-Zabd-hjlp-uw-z]{2}
|| | [Gg][iI][Rr]\W+0[aA]{2}
|| )
|| \b # Replaces $4 == (\W|$).
|| }x;
\end{untested-code}
m/x|xy/ is (probably) less efficient than m/xy?/.
Capturing parens introduce overheads, too.
peace, || India's first litigation-free village
--{kr.pA} || http://tinyurl.com/3oln
--
"Verbosity leads to unclear, inarticulate things." -- ex-V.P. Dan Quayle.