Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Regular Expression: search and replace

by yateeshMN (Initiate)
on Oct 11, 2013 at 19:42 UTC ( [id://1057945]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1057945]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-23 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found