http://www.perlmonks.org?node_id=1230317


in reply to A little golfing challenge: Replacing letters with numbers

haukex: "... solution to produce such a regex character set for any given list of letters."

E.g.
perl -0777 -ne 'print "" . ( join "", "A" .. "Z" ) =~ s/[^$_]/ /gr =~ +s/\B\w+\B/-/gr =~ s/ +//gr'
OUTPUT:
A-IK-NP-TVWYZ
Corresponding link.

For having dashes between VW and YZ I tried to use this:
perl -0777 -ne 'print "" . ( join "", "A" .. "Z" ) =~ s/[^$_]/ /gr =~ +s/(?<=\w)\w*(?=\w)/-/gr =~ s/ +/ /gr'
..but somehow got: A--IK--NP--TV-WY-Z :(

And these worked fine:  s/(?<=\b\w)\w*(?=\w\b)/-/gr ,  s/(\w)\w*(\w)/$1-$2/gr --> A-IK-NP-TV-WY-Z :)