Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expression For Email validation with \+ 1

Status
Not open for further replies.

mts176

MIS
Apr 17, 2001
109
0
0
US
I recently learned about the wonderful Regular Expressions, so I am not even what you would consider proficient in it.

My question is how do I set up a Regex that will validate an email address with a "+" in it.

EX: my+Email@No+Regex.com

I haven't seen an email like this but my boss wants to make sure people that are using them can access our site. Any help would be much appreciated.
 
I feel traps in the question. How about this balancing specificity and complexity?
[tt]var re=/^[\w-+\.]{1,}\@([\da-zA-Z-+]{1,}\.){1,}[\da-zA-Z-+]{2,3}$/i;[/tt]
 
This is the code I am using
Code:
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
Changed to
Code:
 var regexp_user=/^\"?[\w-_\+\.]*\"?$/;
var regexp_domain=/^[\w-\+\.]*\.[A-Za-z]{2,4}$/;
We have 3 seperate pages named the same thing. The one I changed was 1 of 2 wrong ones that are no longer used. This was just a case of not paying close enough attention to detail. Thank you tsuji. You replies have always helped me out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top