Alle venerd? 27 aprile 2007, Josselin ha scritto: > 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 ? > > tfyh > > joss If the text you need to replace is always at the end of the string, you can do: str.sub /\d+$/, '9999' This will replace the text matching the regexp (i.e, one or more digit followed by the end of the line) with the given string (note that this won't change the original string, but return a new one. If you need to change the original one, use sub! instead of sub). I hope this helps Stefano