|Welcome to the Monastery|
Re: A little golfing challenge: Replacing letters with numbers -- onelinerby Discipulus (Abbot)
|on Feb 21, 2019 at 09:40 UTC||Need Help??|
update (also edited the title for personal indexing purpose)
perl -pe 's/[A-Z]/(index" ARNDBCEQZGHILKMFPSTWYV",$&).$"/ge' input.txt
perl -pe 's/\S/(index" ARNDBCEQZGHILKMFPSTWYV",$&).$"/ge' input.txt
the above is wrong.. but..
perl -pe 's/\w/(index"0ARNDBCEQZGHILKMFPSTWYV",$&).$"/ge' input.txt
> The trick with golfing is to wait for Discipulus to have a good idea and steal it from him :P.
best perl compliment I received!
meh.. I had a -1 for not coresponding string in index also it seems that second column is not wanted..
perl -pe 's/\s.//,s/\w/(index"0ARNDBCEQZGHILKMFPSTWYV",$&).$"/eg' input.txt
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.