MaxCarp has asked for the wisdom of the Perl Monks concerning the following question:
For example, if I have xxx12xxxx345xxxxx6789xxxx
(where x is some non-digit character), and I want to insert the word 'found' before each string of digits to give
xxxfound12xxxxfound345xxxxfound6789xxxx
Using
s/[0-9]*/found/g
will (obviously) just insert found to replace all of the digits. How do I modify the regular expression to keep the digit substring and insert the found, along the lines of
s/[0-9'*/found[something]/g
Thank you, Max
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: inserting string using regular expression
by toolic (Bishop) on Aug 16, 2011 at 16:57 UTC | |
|
Re: inserting string using regular expression
by jwkrahn (Abbot) on Aug 16, 2011 at 16:56 UTC |