Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. checking the string

checking the string

Scheduled Pinned Locked Moved ASP.NET
comtutorialquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mairy
    wrote on last edited by
    #1

    how can i check the string that it has at least "@" sign for example .......@hotmail.com i must check that string starting with some text but must end with "@hotmail.com"

    M E V 3 Replies Last reply
    0
    • M Mairy

      how can i check the string that it has at least "@" sign for example .......@hotmail.com i must check that string starting with some text but must end with "@hotmail.com"

      M Offline
      M Offline
      MHASSANF
      wrote on last edited by
      #2

      try with int a = (string).IndexOf("@"); and check the value of a MHF

      1 Reply Last reply
      0
      • M Mairy

        how can i check the string that it has at least "@" sign for example .......@hotmail.com i must check that string starting with some text but must end with "@hotmail.com"

        E Offline
        E Offline
        Exelioindia
        wrote on last edited by
        #3

        Hi, By using regular expression you can able to do it. Just go through the below coading: For more details just visit this site: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/PAGHT000001.asp Regards Exelio

        1 Reply Last reply
        0
        • M Mairy

          how can i check the string that it has at least "@" sign for example .......@hotmail.com i must check that string starting with some text but must end with "@hotmail.com"

          V Offline
          V Offline
          Vipin Venugopal
          wrote on last edited by
          #4

          the best way to do email validation is by using java script. Just cut and paste the following java script. it will work fine. function emailCheck (emailStr) { var checkTLD=1; var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|in fo|pro|museum)$/; 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) { alert("Email address seems incorrect (check @ and .'s)"); return false; } var user=matchArray[1]; var domain=matchArray[2]; for (i=0; i<user.length; i++) { if (user.charCodeAt(i)>127) { alert("Ths username contains invalid characters."); return false; } } for (i=0; i<domain.length; i++) { if (domain.charCodeAt(i)>127) { alert("Ths domain name contains invalid characters."); return false; } } if (user.match(userPat)==null) { alert("The username doesn't seem to be valid."); return false; } var IPArray=domain.match(ipDomainPat); if (IPArray!=null) { for (var i=1;i<=4;i++) { if (IPArray[i]>255) { alert("Destination IP address is invalid!"); return false; } } return true; } var atomPat=new RegExp("^" + atom + "$"); var domArr=domain.split("."); var len=domArr.length; for (i=0;i<len;i++) { if (domArr[i].search(atomPat)==-1) { alert("The domain name does not seem to be valid."); return false; } } if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { alert("The address must end in a well-known domain or two letter " + "country."); return false; } if (len<2) { alert("This address is missing a hostname!"); return false; } return true; }

          Your Email Address:

          Vipin

          J 1 Reply Last reply
          0
          • V Vipin Venugopal

            the best way to do email validation is by using java script. Just cut and paste the following java script. it will work fine. function emailCheck (emailStr) { var checkTLD=1; var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|in fo|pro|museum)$/; 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) { alert("Email address seems incorrect (check @ and .'s)"); return false; } var user=matchArray[1]; var domain=matchArray[2]; for (i=0; i<user.length; i++) { if (user.charCodeAt(i)>127) { alert("Ths username contains invalid characters."); return false; } } for (i=0; i<domain.length; i++) { if (domain.charCodeAt(i)>127) { alert("Ths domain name contains invalid characters."); return false; } } if (user.match(userPat)==null) { alert("The username doesn't seem to be valid."); return false; } var IPArray=domain.match(ipDomainPat); if (IPArray!=null) { for (var i=1;i<=4;i++) { if (IPArray[i]>255) { alert("Destination IP address is invalid!"); return false; } } return true; } var atomPat=new RegExp("^" + atom + "$"); var domArr=domain.split("."); var len=domArr.length; for (i=0;i<len;i++) { if (domArr[i].search(atomPat)==-1) { alert("The domain name does not seem to be valid."); return false; } } if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { alert("The address must end in a well-known domain or two letter " + "country."); return false; } if (len<2) { alert("This address is missing a hostname!"); return false; } return true; }

            Your Email Address:

            Vipin

            J Offline
            J Offline
            J4amieC
            wrote on last edited by
            #5

            That is probably the most over-bloated way of checking an email address ever...considering javascript supports regular expressions. String mashing to determine email validity is not a solution in todays programming world! 1!

            --- How to get answers to your questions[^]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups