Hi Thomas,

On Wed, 2 Jan 2013 14:34:07 +0000
"Hamann, T.D." <thomas.ham...@naturalis.nl> wrote:

> Hello,
> 
> Given a string:
> 
> i994
> 
> where I want to replace the 'i' by a '1' the following regex succesfully
> replaces the letter by a number:
> 
> s/(i)(\d\d\d)/1$2/;
> 
> However, given a string:
> 
> i99o
> 
> where I want to replace the 'i' by a '1' and the 'o' by a '0' (zero), the
> following regex fails:
> 
> s/(i)(\d\d)(o)/1$20/;
> 

You can do:

        s/(i)(\d\d)(o)/1${2}0/;

Or alternatively:

        s/(i)(\d\d)(o)/"1" . $2 . "0"/e;

Regards,

        Shlomi Fish


-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs

The KGB used to torture their victims by having them look at scrolling XSLT
code.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to