Regular Expression for validate email address

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mike1961
    New Member
    • Apr 2008
    • 66

    Regular Expression for validate email address

    Hello.

    I have this Regular Expression for validate email address in my form:

    [php]var re = new RegExp("^[a-z][a-z0-9]*\\.[a-z][a-z0-9]*(\-WEDNES)?@Names\ \.com$", "i");[/php]

    Why invalid this email address ??? :

    mark.d'ausilio-WEDNES@Names.co m

    Is the ' ?
    The ' can exist but is not obligatory...

    Can you help me?
    Thanks
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    #2
    Originally posted by Mike1961
    Why invalid this email address ??? :

    mark.d'ausilio-W
    The regular expression allows for letters and numbers, but that address has special characters in it. I am not sure if " ' " is allowed my most email servers. Even if it works in your specific setup it may not work when others try to send email to you, so it would be a good idea to change it.

    Comment

    • Mike1961
      New Member
      • Apr 2008
      • 66

      #3
      Originally posted by pronerd
      The regular expression allows for letters and numbers, but that address has special characters in it. I am not sure if " ' " is allowed my most email servers. Even if it works in your specific setup it may not work when others try to send email to you, so it would be a good idea to change it.
      these emails are business and assigned by the webmaster for name and surname employee... can not be changed...

      Comment

      • pronerd
        Recognized Expert Contributor
        • Nov 2006
        • 392

        #4
        Originally posted by Mike1961
        these emails are business and assigned by the webmaster for name and surname employee... can not be changed...
        So what? None of that changes what I already told you. Your admins email setup choices do change how regular expressions work. If your emails are going to have special characters then your expression will have to allow them to valid them.

        Comment

        • Mike1961
          New Member
          • Apr 2008
          • 66

          #5
          Originally posted by pronerd
          So what? None of that changes what I already told you. Your admins email setup choices do change how regular expressions work. If your emails are going to have special characters then your expression will have to allow them to valid them.
          How to change regular expression to validate character ' ?

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            If you must, add the single quote in the [a-z0-9] part, i.e. [a-z0-9']

            Comment

            • Mike1961
              New Member
              • Apr 2008
              • 66

              #7
              Originally posted by acoder
              If you must, add the single quote in the [a-z0-9] part, i.e. [a-z0-9']
              many thanks !!!!
              working !!!

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                You're welcome. Never doubted that it wouldn't ;)

                Comment

                Working...