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,}/
You can also use this:
/[..+]/
Though of course, you -want- to get 'nil' instead of a match.
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?
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 Email address - Wikipedia
:with => ???,
:message => 'invalid email format'
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.
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 Email address - Wikipedia
:with => ???,
:message => 'invalid email format'
Or maybe there is an ":without" which uses the negated match?
Kind regards
robert
···
On 11/26/2009 09:46 PM, Ralph Shnelvar wrote:
"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 Email address - Wikipedia
:with => ???,
:message => 'invalid email format'
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 Email address - Wikipedia
:with => ???,
:message => 'invalid email format'