Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Regular expression help required

Options
  • 28-03-2007 5:29pm
    #1
    Registered Users Posts: 7,468 ✭✭✭


    This is for an Asp.net (2) regex validator control. Its the default pattern matcher for a valid email address.
    \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
    

    How can I modify this to ignore trailing whitespace in the email address being validated?


Comments

  • Users Awaiting Email Confirmation Posts: 351 ✭✭ron_darrell


    Been a while but I think this will do it:

    \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*[¬\s]

    Hope that helps
    -RD


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    What I ended up doing in the end was \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\s*

    which ingnores any white space that may be there, including tabs.

    \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*[¬\s]

    Only seems to work if there is a single nonbreaking space present..


  • Registered Users Posts: 6,509 ✭✭✭daymobrew


    I found a suggestion in the Perl FAQ. It includes a link to a script that does a complete check (including contacting the email server). I'm sure both could be ported to ASP.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Thanks daymobrew but its just for a form processing. It doesn't have to be an existing email address, just as long as its resembles one.


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    Phil you might want to check out Regulazy its great at working these out for you ... hence the lazy bit in the name

    http://tools.osherove.com/Default.aspx?tabid=182


  • Advertisement
Advertisement