Tim Greer
12/14/2008 7:16:00 PM
Iñaki Baz Castillo wrote:
> El Domingo, 14 de Diciembre de 2008, David A. Black escribió:
>> The first thing that comes to mind:
>>
>> text.sub(/(X-Level: )(\*+)/) { $1 + 'X' * $2.size }
>>
>> or, in Oniguruma, using look-behind:
>>
>> text.sub(/(?<=X-Level: )(\*+)/) { 'X' * $1.size }
>
> Thanks, this is valid in Ruby, but I understand such a operation is
> not feasible with "sed" command, is it?
> I'm not sure yet about if I'll need to do this script in Ruby or
> Shell.
>
> Thanks a lot.
>
sed '/^X-Level: /s/\*/X/g'
~]$ echo "X-Level: ****" | sed '/^X-Level: /s/\*/X/g'
X-Level: XXXX
~]$ echo "X-Level: ***********" | sed '/^X-Level: /s/\*/X/g'
X-Level: XXXXXXXXXXX
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!