From: "David A. Black" Date: 2008-12-15T04:18:46+09:00 Subject: Re: Help with an "easy" regular expression substitution --1926193751-198042275-1229282769=:4313 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-198042275-1229282769=:4313" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-198042275-1229282769=:4313 Content-Type: TEXT/PLAIN; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT Hi -- On Mon, 15 Dec 2008, 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. Just in case: sed -Ee '/X-Level: \*+/s/\*/X/g' David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) --1926193751-198042275-1229282769=:4313-- --1926193751-198042275-1229282769=:4313--