From: Gavin Sinclair Date: 2003-11-15T11:37:05+09:00 Subject: Re: substring: to the end of the string On Saturday, November 15, 2003, 12:24:42 PM, Rodrigo wrote: > class String > def substring > /(^...)(.*)\z/ =~ self > return $2 > end > end > "123456".substring > = >"456" > Now...... > I am just wondering how can I build dinamically the Regexp > I mean ... > "123456".substring(5) > = > "6" > "123456".substring(4) = >> "56" > ideas ? Regexen are overkill here. class String def substring(m, n=-1) self[m..n] end end Gavin