Re: sed conversion of digits to "x"
From: Ed Morton (morton_at_lsupcaemnt.com)
Date: 11/23/05
- Next message: James: "Re: sed conversion of digits to "x""
- Previous message: Ed Morton: "Re: sed conversion of digits to "x""
- In reply to: Ed Morton: "Re: sed conversion of digits to "x""
- Next in thread: James: "Re: sed conversion of digits to "x""
- Reply: James: "Re: sed conversion of digits to "x""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 22 Nov 2005 18:32:59 -0600
Ed Morton wrote:
> James wrote:
>
>> In perl,
>> $ cat conv.pl
>> sub f {
>> my $s = shift; $s =~ s/\d/x/g; return $s
>> }
>> while (1) {
>> if (/ [\d\.]+ /) {
>> print $`.f($&); s/^$`$&//
>> } else {
>> print; last
>> }
>> }
>>
>> $ echo " 12.3 a1b2 foo12 3.4 5.67 " | perl -n conv.pl
>> xx.x a1b2 foo12 x.x 5.67
>
>
> Ahem: notice that final 5.67 in your output....
It'll also wrongly convert " 1.2.3 " to " x.x.x ".
Ed.
- Next message: James: "Re: sed conversion of digits to "x""
- Previous message: Ed Morton: "Re: sed conversion of digits to "x""
- In reply to: Ed Morton: "Re: sed conversion of digits to "x""
- Next in thread: James: "Re: sed conversion of digits to "x""
- Reply: James: "Re: sed conversion of digits to "x""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]