Email id validation regexp

Hello all,
Can any body please help me in writing a reg exp for email id validation that would cover all possibilities of validating a email id?
I had tried searching few on net but some test cases for the same faild.
thanks in advance
Aniruddha

Ani-4-U wrote:
Can any body please help me in writing a reg exp for email id validation that would cover all possibilities of validating a email id?
I had tried searching few on net but some test cases for the same faild.
Do you have actual requirements for this?
Why does that matter - well look at the links posted and read them for the complexity of validating that an email address is valid in terms of the RFE that defines it.
However, note that despite that such an address might not work at all. Even though it is perfectly valid.
So if your requirements are to only accept email addresses that work then you need something quite a bite more complicated that simply validating that it meets the RFE. And if you don't need an address that actually works then does it matter if it is valid or not?

Similar Messages

  • Email address validation pattern

    First off, I'm using JDK 1.4.2_07. What I'm trying to do is validate email addresses with the String.matches(String pattern) function. What I'm having a problem with is coming up with the regex pattern that represents any syntactically valid email address. If someone has a regex pattern that does represent any syntactically valid email address, I would appreciate it if you posted it in a reply to this message. Thanks!
    --Ioeth                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Here is the struts implementation of email address validation:
    <validator name="email"
    classname="org.apache.struts.validator.FieldChecks"
    method="validateEmail"
    methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
    depends=""
    msg="errors.email">
    <javascript><![CDATA[
    function validateEmail(form) {
    var bValid = true;
    var focusField = null;
    var i = 0;
    var fields = new Array();
    oEmail = new email();
    for (x in oEmail) {
    if ((form[oEmail[x][0]].type == 'text' ||
    form[oEmail[x][0]].type == 'textarea') &&
    (form[oEmail[x][0]].value.length > 0)) {
    if (!checkEmail(form[oEmail[x][0]].value)) {
    if (i == 0) {
    focusField = form[oEmail[x][0]];
    fields[i++] = oEmail[x][1];
    bValid = false;
    if (fields.length > 0) {
    focusField.focus();
    alert(fields.join('\n'));
    return bValid;
    * Reference: Sandeep V. Tamhankar ([email protected]),
    * http://javascript.internet.com
    function checkEmail(emailStr) {
    if (emailStr.length == 0) {
    return true;
    var emailPat=/^(.+)@(.+)$/;
    var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
    var validChars="\[^\\s" + specialChars + "\]";
    var quotedUser="(\"[^\"]*\")";
    var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
    var atom=validChars + '+';
    var word="(" + atom + "|" + quotedUser + ")";
    var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
    var matchArray=emailStr.match(emailPat);
    if (matchArray == null) {
    return false;
    var user=matchArray[1];
    var domain=matchArray[2];
    if (user.match(userPat) == null) {
    return false;
    var IPArray = domain.match(ipDomainPat);
    if (IPArray != null) {
    for (var i = 1; i <= 4; i++) {
    if (IPArray[i] > 255) {
    return false;
    return true;
    var domainArray=domain.match(domainPat);
    if (domainArray == null) {
    return false;
    var atomPat=new RegExp(atom,"g");
    var domArr=domain.match(atomPat);
    var len=domArr.length;
    if ((domArr[domArr.length-1].length < 2) ||
    (domArr[domArr.length-1].length > 3)) {
    return false;
    if (len < 2) {
    return false;
    return true;
    }]]>
    </javascript>
    </validator>

  • An error occurred during email account validation

    Hello everyone 
    I have a seriously annoying problem with my BB Curve!
    I added a language on to my phone using the Desktop Manager which resulted in the phone being backed up and reinstalled (like a reformat but the data wasn’t lost). Ever since then I am unable to access my email account information that I set up on the phone and wasn’t receiving emails (this coincided with the Blackberry blackout). After that I deleted the email account on using the website email account access for blackberry and re-entered my account information, this allowed the emails to come through my phone but I still cant access my email account information.
    If I go to Main Menu > Setup > Email Accounts > Internet Mail Account the phone will hang up while trying access information
    If I go to Messages > Options > Email Account Management, I get the following information “Unable to open email setup application. Contact your wireless service provider” I have called Vodafone for the past 5 days now but they are of no help.
    If I try to edit the account information (like signatures) on the hutch.blackberry.com website, I get the following error “An error occurred during email account validation. Please check your information and try again.”
    Has this happened to anyone before? Is there any solution to this problem?
    My phone is currently on Software version 6.0 Bundle 2342
    Please help!!!
    Gwen

    I would keep trying, or wait and try again. There could be a server issue which will be resolved.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • BB 8520 Error: An error occurred during email account validation

    Device info
    Your carrier: TMN Portugal
    Model info and OS version: 8520 V 5.0.0.822
    Hello,
    im getting a problem:
    I had my email account configured on a BB. Everything was working fine. I changed for a new Blackberry, and when i switched my device on www.tmn.blackberry.com it asked me to validate my accounts. And when i was trying to validate my email [email protected] i got this error: An error occurred during email account validation.
    The problem is that all the settings are fine.Username, password and server name.
    And the wierd thing is that i have 2 more blackberrys in my company, with a masterphone.pt email working. But when i try to configure another they all give this error now. No one can change their device, or they will lose the email configuration.

    Hey s_roy12,
    Welcome to the forums. 
    Check out How to integrate a Microsoft Outlook Web Access email address with a BlackBerry Internet Service account http://bbry.lv/oXXGLx.
    Let us know if you have any other issues.
    -SR
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • Error during email account validation

    I'm trying to activate my email account, and keep getting the message "An error occurred during email account validation. Please check your information and try again."
    Any advice?

    Hey s_roy12,
    Welcome to the forums. 
    Check out How to integrate a Microsoft Outlook Web Access email address with a BlackBerry Internet Service account http://bbry.lv/oXXGLx.
    Let us know if you have any other issues.
    -SR
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • Email field validation

    Please let me know the email field validation
    Regards,
    Pallavi

    I made an awesomely good email verification string:
    '^[[:alnum:]][[:alnum:]_\-\.]*@([[:alnum:]]([[:alnum:]\-]*[[:alnum:]])?\.)+[[:alpha:]]+$'Try to break it for me :)
    -UPDATE 1-
    '^[[:alnum:]]([[:alnum:]_\-\.]*[[:alnum:]])?@([[:alnum:]]([[:alnum:]\-]*[[:alnum:]])?\.)+[[:alpha:]]+$'Forgot the last character of the local part has to be alnum :)
    Argh, hyphens still break it in the local part.
    -UPDATE 2-
    '^[[:alnum:]]([-[:alnum:]_\.]*[[:alnum:]])?@([[:alnum:]]([-[:alnum:]]*[[:alnum:]])?\.)+[[:alpha:]]+$'Hah, apparently hyphens can't be escaped from...
    You have to put them at the start or end of the list.

  • Need email format validation code

    I m looking for an email format validation code written in J2ME. It should just verify the format, not if the email address exists or not.

    Hi there
    I would like to use this to validate across multiple addresses... so i tried...
    ^((\s*\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|co.uk|co.in|in|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)\s*)(;))\s*{1,100}?)?(\s*\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|co.uk|co.in|in|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)\s*)(?|;))$
    but it doesn't work... it validates against 1 address (with or without a ";" separator... ) but no more...
    Any ideas ?

  • Help needed in email address validation !

    Hi all,
    I am developing a web page in which there is a text box and a submit buttion. User enters his email id and clicks the button. As soon as the button is clicked, the email- address validation should be done.
    some thing like,
    only one @ shold be there,
    the address should terminate with .net, .com, .org.....
    there should not be any special characters like / , ?, < > \ etc..;
    It should be in JSP or JAVA Script
    Can anyone help me ????
    Regards
    AShvini

    function validateEmail(email) {
        // A very simple email validation checking.
        // you can add more complex email checking if it helps
        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;
        return false;
    }Here's one in JS. A little bit of modification could make it suited to your requirements!

  • Email account validation

    I am having problems configuring a specific account to my device. I know the email address works, as it is doing so in Outlook and I have also used the BlackBerry Email Validation Tool which also confirms the same. However everytimne I receive the following message:
    "An error occured duruing email account validation. Please check your information and try again."
    Thanks in advance.

    jdenham wrote:
    but I dont know how to contact RIM and have the IP resolved.
    To answer that part -- you have no direct method to contact RIM (well, not for free at least). Your sole method, as per your contract, is to contact your mobile service provider and, if they need to, they can escalate into RIM at no cost to you. There is no method to, for free, bypass as that is what is required per all contracts covering formal support services for BBs.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • EMail Address Validation - Shell Script

    Hi,
    I have a custom concurrent program (Shell Script Program). One of the input parameter is Email address.
    In my code, I need to validate email address format (Ex: [email protected])
    Can anyone paste the code snippet.
    I have tried with the below validation
    case $EMAIL_ID in
         *@?*.?*) echo "Email Address Validated.";;
         *) echo "Invalid Email Address. Please enter the correct format of email address and re-run the program";
    exit 1;;
    esac
    This validation is failing in this scenario xxx,[email protected] / xxx [email protected] (If user enters the email address with comma or a blank space. This validation is returning success message)
    Regards
    BS

    Please look up the syntax for this by typing
    man mailx
    on the shell command prompt.
    Please stop asking Unix specific questions in an Oracle forum. There are more than enough Unix forums on the Internet.
    Please refrain from asking further doc questions here.
    You are in gross violation of the 'Forums Etiquette' post.
    Sybrand Bakker
    Senior Oracle DBA

  • Email Address Validation in JavaScript?M

    Hi, everyone,
    I need to validate the email address in javascript.
    Does anyone has a COMPLETED solution?
    Any reply would be valuable.
    Thank you in advance.

    BalusC wrote:
    Modi wrote:
    you can validate email address using java file.
    Take a look here
    [http://www.devdaily.com/blog/post/java/java-email-address-validation-class|http://www.devdaily.com/blog/post/java/java-email-address-validation-class]
    This is written by a 10 year old child and this identifies [email protected] as valid. It is not.
    [http://www.devx.com/tips/Tip/28334|http://www.devx.com/tips/Tip/28334]
    This identifies [email protected] as valid. It is not.
    [http://java-servlet-jsp-web.blogspot.com/2009/06/best-url-and-email-validation-using.html|http://java-servlet-jsp-web.blogspot.com/2009/06/best-url-and-email-validation-using.html]
    This does not validate .museum tld's, nor email addresses with RFC822/5322 valid characters like ~, #, & and so on.
    With other words, come up with better suggestions, kid.
    >
    >you can validate email address using java file.
    Take a look here
    [http://www.devdaily.com/blog/post/java/java-email-address-validation-class|http://www.devdaily.com/blog/post/java/java-email-address-validation-class]
    This is written by a 10 year old child and this identifies [email protected] as valid. It is not.
    [http://www.devx.com/tips/Tip/28334|http://www.devx.com/tips/Tip/28334]
    This identifies [email protected] as valid. It is not.
    [http://java-servlet-jsp-web.blogspot.com/2009/06/best-url-and-email-validation-using.html|http://java-servlet-jsp-web.blogspot.com/2009/06/best-url-and-email-validation-using.html]
    This does not validate .museum tld's, nor email addresses with RFC822/5322 valid characters like ~, #, & and so on.
    With other words, come up with better suggestions, kid.
    Okey fine.
    Now see these links
    [https://glassfish.dev.java.net/source/browse/glassfish/mail/src/java/javax/mail/#dirlist|https://glassfish.dev.java.net/source/browse/glassfish/mail/src/java/javax/mail/#dirlist]
    [https://glassfish.dev.java.net/source/browse/glassfish/mail/src/java/javax/mail/internet/InternetAddress.java?rev=1.6&view=markup|https://glassfish.dev.java.net/source/browse/glassfish/mail/src/java/javax/mail/internet/InternetAddress.java?rev=1.6&view=markup]
    I guess u will get right answer from these links and code also whatever u wants to do.
    might be it will not completely useful but i think u will get some ideas.

  • Email address validation, is there a way to use Regex or other fuzzy searching?

    I would like to use PL/SQL for Email address validation, is there a way to use Regex (regular expressions) or some other fuzzy searching for that? Using % and _ wildcards only take you so far...
    I need something that will verify alphanumeric charectors (no ",'.:#@&*^ etc.) any ideas?
    Current code:
    if email not like '_%@_%.__%' or email like '%@%@%' or email like '% %' or email like '%"%' or email like '%''%' or email like '%
    %' then
    The last line is to make sure there are no linebreaks in the middle of the email address, is there a better way to signify a line break, like \n or an ascii equivilent?

    Michael:
    The as noted in the previous post, DBI is a Perl package that allows Perl to talk to various databases, including Oracle. We use DBI on several UNIX servers, and it does not require ODBC, and I have always found it to be extremely quick. Things may be different in the Windows world.
    If you are spooling files out to run through Perl anyway, you may want to take a look at DBI. You could probably modify your existing scripts to use DBI fairly easily. The basic structure using DBI is like:
    use DBI;
    my dbh;       # A database handle
    my sth;       # A statment handle
    my sqlstr;    # SQL statement
    my db_vars;   # Variables for your db columns
    # Connect to the database
    $dbh = DBI->connect( "dbi:Oracle:service_name","user/password");
    $sqlstr = 'SELECT * FROM emp WHERE id = ?' # even takes bind variables
    #Prepare statement
    $sth = $dbh->prepare($sqlstr);
    $sth->execute(12345);  # Execute with values for bind if desired
    # Walk the "cursor"
    while (($db_vars) = $sth->fetchrow_array()) {
       your processing here

  • BP Email Address validation

    Hi,
    Is there anyway to turn off email address validation which occurs when creating Business partner.
    For example, abc.com@acb is an invalid email id and the system doesnt allow to save BP. But i want to save the BP even though email id is invalid.
    Thanks,
    Karthik.

    Hi Kartik,
    Only way to remove validation is to change the standard code.Go to program LSZA0F33 and comment FM
    SX_INTERNET_ADDRESS_TO_NORMAL.Please refer the below mentioned code.
    *{   DELETE         PDCK902820                                        1
    *\  CALL FUNCTION 'SX_INTERNET_ADDRESS_TO_NORMAL'
    *\       EXPORTING
    *\            address_unstruct    = unstruct
    \           COMPLETE_ADDRESS    = 'X'
    *\       IMPORTING
    *\            address_normal      = normal
    \           local               =
    \           domain              =
    \           COMMENT             =
    \            addr_normal_no_up_with_comment                   "1280i
    \                                = normal_w_umlaut            "1280i
    *\       EXCEPTIONS
    *\            error_address_type  = 1
    *\            error_address       = 2
    *\            error_group_address = 3
    *\            OTHERS              = 4.
    *\  IF sy-subrc <> 0.
    \550i+
    *\    error_table-msg_id     = sy-msgid.
    *\    error_table-msg_type   = sy-msgty.
    *\    error_table-msg_number = sy-msgno.
    *\    error_table-msg_var1   = sy-msgv1.
    *\    error_table-msg_var2   = sy-msgv2.
    *\    error_table-msg_var3   = sy-msgv3.
    *\    error_table-msg_var4   = sy-msgv4.
    \    error_table-fieldname  = 'SMTP_ADDR'.                   "863i
    *\    APPEND error_table.
    \    worst_error = c_error_occurred.                         "863u
    *\    IF g_check_address IS INITIAL.
    \      error_table-msg_type = c_warning_occurred.            "863u
    *\      MODIFY error_table
    \      TRANSPORTING msg_type  WHERE msg_type = c_error_occurred."863u
    \      worst_error = c_warning_occurred.                     "863u
    *\      help_smtp = smtp-smtp_addr.
    *\      TRANSLATE help_smtp TO UPPER CASE.                 "#EC TRANSLANG
    *\      CONDENSE help_smtp.
    *\      p_wa_adr6-smtp_srch = help_smtp.
    *\    ENDIF.
    *\    returncode = worst_error.
    \550i-
    *\  ELSE.
    *\    TRANSLATE normal TO UPPER CASE.                      "#EC TRANSLANG
    *\    p_wa_adr6-smtp_srch = normal-address.
    \    p_wa_adr6-smtp_addr = normal_w_umlaut-address.          "1280i
    *\  ENDIF.
    *}   DELETE
    *{   INSERT         PDCK902820                                        2
    Code inserted
        p_wa_adr6-smtp_srch = unstruct-address.
        p_wa_adr6-smtp_addr = unstruct-address.

  • Email form validation

    Having trouble with an email form validation. I have an email
    field that is optional. Therefore, if the user leaves it blank, the
    form should submit. However, I also want to check that if the user
    did fill out the email address, it is valid. I am checking that if
    it does not contain and '@', a '.' or does contain a ',' to give an
    error. Whenever I submit a blank form, it keeps giving error that
    the email address is not valid. Here is my code:
    <cfif (Len(Trim(form.email)) IS 0)>
    <cfif form.email does not contain "@" or form.email does
    not contain "." or form.email contains ",">
    <script language="JavaScript">
    alert("Your email address is not valid. Please correct it
    and resubmit the form.")
    history.back()
    </script>
    <cfabort>
    </cfif>
    </cfif>
    Please assist. Thanks, Lumpia.

    duplicate post

  • Pattern for email attribute validation.

    I generated an schema for a web service which includes an email attribute, for which I developed a pattern to filter invalid emails but I'm getting facet errors during the schema object creation. My schema works perfectly well in XMLSpy but Oracle's XML parser/schema object fails.
    the pattern I am using is:
    "([a-zA-Z0-9_\\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)"
    which includes some OR logic and nested patterns to validate the email.
    I was able to track that using something like (([a-zA-Z0-9\-]+\.)+)) would not be correctly validated in Oracle's XML parser and that \. will cause the schema object creation to fail with facet errors.
    I do not know if this is related to the current implementation of the validating parser or something else but I cannot find information on the current implementation that oracle supports (besides a version number). Where can I find information on this... does anyone happen to have a pattern which will validate email addresses and work under oracle parser?
    Thanks,
    Fedro

    Yes, this may related to our implementation for the regular expressions.
    Would you send me a simple test case at [email protected] If this is bug, we will fix it.
    Thanks.

Maybe you are looking for