On 27.04.2007 09:29, Josselin wrote: > I have a string : str = "/proposal/list/31551" > > I would like to change the 31551 by another value "9999", but I don't > see whicj method I should use ? > > str.each and block ? or str.rindex('/') and concatenating the new value ? How about irb(main):006:0> str = "/proposal/list/31551" => "/proposal/list/31551" irb(main):007:0> str[%r{\d+$}]="9999" => "9999" irb(main):008:0> str => "/proposal/list/9999" If it's a file name you could also do irb(main):012:0> File.join(File.dirname(str), "9999") => "/proposal/list/9999" I estimate there are another 5 million other ways around. :-) Kind regards robert