You still could use s///. You just need to take out the '+' sign like so:
$number =~ s/\d/x/g;
If you use the regexp above for the following example here is what you get:
$number = '11111 11111'; # before regexp
$number =~ s/\d/x/g; # perform regexp
$number = 'xxxxx xxxxx'; # after regexp
If you leave the '+' sign in this is what happens:
$number = '11111 11111'; # before regexp
$number =~ s/\d+/x/g; # perform regexp
$number = 'x x'; # after regexp
The '+' was telling PERL to group as many numbers as it could into one
substitution.
Brad
> -----Original Message-----
> From: darren chamberlain [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 12, 2001 12:30 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Regrex substitution!!!
>
>
> Fernando <[EMAIL PROTECTED]> said something to this effect on 07/11/2001:
> > I have a credit card number that I want to change to email a
> > reciept to the customer. This is that I want:
> >
> > I have this number: e.j. 1111 8578 596 8552
> > I want to convert all the number to "x" like that xxxx xxx xxxx
> >
> > when I use this:
> >
> > $number = "1111 8578 596 8552";
> > $number =~ s/\d+/x/g;
> >
> > Perl give only one "x" in the result.
>
> Try tr/// rather than s///
>
> $number =~ tr/[0-9]/x/;
>
> Faster, and it does what you want.
>
> (darren)
>
> --
> "The first rule of magic is simple. Don't waste your time waving your
> hands and hoping when a rock or a club will do."
> -- McCloctnik the Lucid
>