|
Posted by Jens Thoms Toerring on June 26, 2008, 9:45 am
Please log in for more thread options
> >
> > how to replace a line's all characters (case-insensitive) NOT equal to any
> > of say, [ABCDE] to K?
> >
> > e.g.
> >
> > I am the sunny boy.
> > to
> > KKaKKKKeKKKKKKKbKKK
> Assuming you mean lower case [abcde], you can do it like this:
> $a = 'I am the sunny boy.';
> ($b = $a) =~ s/[^abcde]/K/g;
> print "$b\n";
And to make it case-insensitive just add 'i' to the match flags:
($b = $a) =~ s/[^ABCDE]/K/gi;
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
|