in reply to Regular Expression: search and replace

This is my first answer after joining perlmonks. Answer is already posted, but here is perl one liner for doing same thing.

'num' is a file containing numbers.

$ cat num Hello 12345 world 23456 777381 89651

perl one liner which you can execute in command line for your answer.

$ perl -lpne 's/\d/qw(zero one two three four five six seven eight nin +e)[$&]/ge' num
A minor correction. Same can be achieved through.
$ perl -lpe 's/\d/qw(zero one two three four five six seven eight nine +)[$&]/ge'

Once you finish regexes, you can have a look into perl command line options to know what magic is going on in above command.

Replies are listed 'Best First'.
Re^2: Regular Expression: search and replace
by toolic (Bishop) on Oct 11, 2013 at 19:53 UTC
      Thanks for correction. I will update.