From: Robert Klemme Date: 2009-11-27T21:57:51+09:00 Subject: Re: Pattern match to fail if two periods in a row 2009/11/27 Aldric Giacomoni : > Ralph Shnelvar wrote: >> How does one create an expression that fails if there are two or more >> periods >> (e.g. "..") in a row? > > As previously mentioned, you can use this: > /\.{2,}/ That only positively matches strings which contain at least two dots in a row. OP specifically wanted to _not_ have a match for two dots in a row. > You can also use this: > /[..+]/ Did you test that? How should this expression match two dots in a row? You have define a character class with "." and "+" where one dot is redundant. irb(main):001:0> /[..+]/ =~ "+" => 0 irb(main):002:0> /[..+]/ =~ "." => 0 > On the other hand, if you are looking to validate an email address, > there are already rails plugins that do that (and more) - so why > reinvent the wheel? :) If he's reinventing the wheel then that's certainly not a good idea. I just guess that you are talking about a different wheel. :-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/