elmuel has asked for the wisdom of the Perl Monks concerning the following question:
Hi, This is also my first time posting with the Monks, so please let me know if I'm not following the guidelines as well.
I have two regex questions. First, when you're using s/// can you have multiple options for replacing text? I saw that you could do this with a hash array but was looking for just a regex solution if possible.
For instance, I have text such as
oldsmobile_eighty_eight
oldsmobile_ninety_nine
which I'd like to replace with
olds_88
olds_99
I was looking for something similar to translate (but for longer strings instead of individual letters) where I could say change 'eighty eight' to 88 and 'ninety_nine' to 99 if 'oldsmobile' is matched.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Substitution with multiple options for capture and replace.
by Anonymous Monk on Nov 09, 2009 at 21:57 UTC | |
by elmuel (Initiate) on Nov 10, 2009 at 19:21 UTC | |
|
Re: Substitution with multiple options for capture and replace.
by toolic (Bishop) on Nov 10, 2009 at 01:44 UTC |