regarding validation of email address.

Discussion in 'Ruby' started by Vamsi Krishna, Jul 28, 2008.

  1. hi all

    i used the following reg. expression

    /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
    for validating an email address.

    and its work nice. *but i need to add + in the validation as i need it

    ex:

    so in order to validate this where should i put + symbol in regular
    expression so that i send emails to .


    thanks in advance.
    --
    Posted via http://www.ruby-forum.com/.
    Vamsi Krishna, Jul 28, 2008
    #1
    1. Advertising

  2. 2008/7/28 Vamsi Krishna <>:
    > hi all
    >
    > i used the following reg. expression
    >
    > /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
    > for validating an email address.
    >
    > and its work nice. *but i need to add + in the validation as i need it
    >
    > ex:
    >
    > so in order to validate this where should i put + symbol in regular
    > expression so that i send emails to .


    Have a look at http://tfletcher.com/lib/rfc822.rb

    Regards,
    Farrel
    Farrel Lifson, Jul 28, 2008
    #2
    1. Advertising

  3. Vamsi Krishna

    Kyle Schmitt Guest

    On Mon, Jul 28, 2008 at 9:19 AM, Phlip <> wrote:
    > E-mail address validation is a FAQ in the Regular Expression discipline.
    >
    > You can't do it. No Regexp can successfully distinguish valid from invalid
    > e-mail addresses, in all their permutations.
    >
    > If you want to provide a simple defense against typographical errors, such
    > as omitting the @, you must write a Regexp that is too wide, and will permit
    > some ill-formed addresses to slip past.
    >
    > --
    > Phlip

    Actually I believe it _can_ be done, but it's next to useless to do so.
    There's a nasty regex that claims to validate all RFC 2822 compliant
    email addresses over at regular-expressions.info, and it was done so
    just to show that it really is a bad idea. The regex Is really really
    hideous, but the article on why not to do it is well done.
    http://www.regular-expressions.info/email.html

    For those who don't want to read the article, the last paragraph is
    one that should be remembered when using regexes..

    "Don't blindly copy regular expressions from online libraries or
    discussion forums. Always test them on your own data and with your own
    applications."




    --Kyle
    Kyle Schmitt, Jul 28, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark B
    Replies:
    3
    Views:
    2,110
    Mark B
    Jul 22, 2009
  2. Zeynel
    Replies:
    1
    Views:
    559
    alex23
    Dec 6, 2010
  3. David, the great

    Validation on email address

    David, the great, Jun 17, 2008, in forum: ASP General
    Replies:
    6
    Views:
    173
    Daniel Crichton
    Jun 18, 2008
  4. Bob

    Email Address Validation

    Bob, Jun 21, 2005, in forum: Perl Misc
    Replies:
    10
    Views:
    323
  5. Replies:
    5
    Views:
    257
    Dr John Stockton
    Dec 23, 2005
Loading...

Share This Page