From: Ralph Shnelvar on
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
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
[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

>>> "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
[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'
>
>
>
>
>
>