From: William James Date: 2008-12-15T15:52:40+09:00 Subject: Re: Help with an "easy" regular expression substitution I単aki Baz Castillo wrote: > Hi, I'm getting crazy to get a theorically easy substitution: > > I've a file with a header: > X-Level: *** > where the number of "*" is variable (from 0 up to 10). > > And I just want to replace "*" by "X", so get: > X-Level: XXX > > I don't get it since I don't know how to replace ANY number of "*" > with the same number of "X" just in the header "X-Level". > > Any help? Thanks a lot. s = "X-Level: ***" ==>"X-Level: ***" s[ /X-Level: (\**)/, 1 ] = $1.gsub("*", "X") ==>"XXX" s ==>"X-Level: XXX"