SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Shiver me timbers!! anthony_irl's Avatar
    Join Date
    Aug 1999
    Location
    Dublin, Ireland
    Posts
    495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Silly regexp problem

    Hi all,

    I'm having a problem with a regular expression that checks for a valid email address. I'm limited in what I can do with the source as an outside dev company made it for us and I'm just adapting a small bit of it. I have the following regexp:

    Code:
    var reg2 = /(^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)(\;\S)?)+$/;
    Basically i need to check for the following:

    1. either a straight email address
    or 2. multiple email addresses seperated by a semi-colon and single space: me@me.com; you@you.com

    I thought the regular expression I wrote above should have done it but it throws an error. Any help would be really appreciated.
    Anthony - How's tings?

    24 hours in a day, 24 beers in a case. Coincidence? I think not.
    Contact me by: PM Email NEW! Carrier Pigeon

  2. #2
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    Finland
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't test this but I think it'll work.

    var reg2 = /^(.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)(\;\S)?)+$/;

    The problem was that the regexp matched the start of the line (^) multiple times.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •