From: Michael Kohl Date: 2009-07-02T02:36:27+09:00 Subject: Re: Question about regex and date formatting On Wed, Jul 1, 2009 at 6:21 PM, Älphä Blüë wrote: > date = "2009-06-01" > date =~ /^\d{4}-\d{2}-\d{2}$/ > > returns => 0 Remember that 0 in Ruby is not false, only 'nil' and false are. 0 is the index of where in your string your match starts. Your RegEx is ok: >> m=/\d{4}-\d{2}-\d{2}/.match(date) => # >> pp m # Also this little change should make it obvious what happens: >> date = "blablabla2009-06-01" => "blablabla2009-06-01" >> date =~ /\d{4}-\d{2}-\d{2}$/ => 9 HTH, Michael -- Il pinguino ha rubato il mio lanciafiamme. Blog: http://citizen428.net/ Twitter: http://twitter.com/citizen428