Prev: Net::Telnet - How to send keystrokes like ESC
Next: Do the inplace edit without backup file generated.
From: Ralph Shnelvar on 26 Nov 2009 14:51 Ok ... I really tried. And I used http://rubular.com/ (really nice) And I read and reread the pickaxe book section on regular expressions. In other words ... I tried. So .. How does one create an expression that fails if there are two or more periods (e.g. "..") in a row?
From: Jesús Gabriel y Galán on 26 Nov 2009 15:12 On Thu, Nov 26, 2009 at 8:51 PM, Ralph Shnelvar <ralphs(a)dos32.com> wrote: > Ok ... I really tried. And I used http://rubular.com/ (really nice) > > And I read and reread the pickaxe book section on regular > expressions. > > In other words ... I tried. > > So .. > > How does one create an expression that fails if there are two or more periods > (e.g. "..") in a row? >> "abc..def" !~ /\.\./ => false One easy way is to use the negated match operator (!~). Then the regexp is trivial. Jesus.
From: Louis-Philippe on 26 Nov 2009 15:14 [Note: parts of this message were removed to make it a legal post.] if ! /\.{2,}/ or something 2009/11/26 Ralph Shnelvar <ralphs(a)dos32.com> > Ok ... I really tried. And I used http://rubular.com/ (really nice) > > And I read and reread the pickaxe book section on regular > expressions. > > In other words ... I tried. > > So .. > > How does one create an expression that fails if there are two or more > periods > (e.g. "..") in a row? > > >
From: Ralph Shnelvar on 26 Nov 2009 15:46 >>> "abc..def" !~ /\.\./ =>> false I don't think that "abc..def" !~ /\.\./ is a regular expression. /\.\./ is a regular expression. Basically ... I need something that will work in a Rails validates_format_of # Reject if the email address has two periods in a row validates_format_of :email, # See http://en.wikipedia.org/wiki/E-mail_address :with => ????, :message => 'invalid email format'
From: Louis-Philippe on 26 Nov 2009 16:49 [Note: parts of this message were removed to make it a legal post.] so then only trying to match: /\w+\.?\w*/ should do 2009/11/26 Ralph Shnelvar <ralphs(a)dos32.com> > > >>> "abc..def" !~ /\.\./ > =>> false > > I don't think that > "abc..def" !~ /\.\./ > is a regular expression. > > /\.\./ > is a regular expression. > > > Basically ... I need something that will work in a Rails > validates_format_of > > # Reject if the email address has two periods in a row > validates_format_of :email, > # See http://en.wikipedia.org/wiki/E-mail_address > :with => ????, > :message => 'invalid email format' > > > > > >
|
Next
|
Last
Pages: 1 2 Prev: Net::Telnet - How to send keystrokes like ESC Next: Do the inplace edit without backup file generated. |