s/[A-Za-z]/*|&|ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*/g
s/\*|\(.\)|[A-Za-z]*\1[A-Za-z]\{25\}\([A-Za-z]\)[A-Za-z]*\*/[\1\2]/g

Ah, that's a nice solution. I was considering the following:

This is inspired me the following in turn, which is faster than my ultra-compact version and also uses little pattern space. I haven't benchmarked it against yours:

y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
h
y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
G
s/^/\n/
:f
s/\n\([A-Za-z]\)\(.*\)\(\n\)\(.\)/[\1\4]\3\2\3/
s/\n\([^A-Za-z]\)\(.*\)\(\n\)./\1\3\2\3/
/\n\n$/!bf
s///



Reply via email to