in reply to Re: howto replace part of a string
in thread howto replace part of a string
Well, for starters, you're using 5, 4, and *, rather than 10 and 20. Secondly, you're ignoring the warning message:
(You are using strict and warnings, right?) Third - what's with the ($a = $a )? Finally, you've inverted the problem. You're replacing everything except characters 6 through 9. You probably want something like:\1 better written as $1 at ./z.pl line 7.
Or, potentially simpler:$a =~ s/^(\S{5})\S{4}/$1xxxx/;
But what you really want is still substr.$a =~ s/(?<=^\S{5})\S{4}/xxxx/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: howto replace part of a string
by jeanluca (Deacon) on Jun 14, 2006 at 16:08 UTC |