How to find an  Email id  in the large text 
Ex : My Name is yanju. and my email id is yanju024@gmail.com. and my friend email id is vijju@reddif.com
In the above text we need to find out the emails.
Ans: 
      var SimpleString = "My email id is yanju024@gmail.com and my friend email id is vijju@gmail.com";
      var myArray = SimpleString.split(" ");
      for (var i = 0; i < myArray.length; i++) 
      {
              var res = myArray[i].lastIndexOf(".");
              var res1 = myArray[i].indexOf("@");
               if(res > 0 && res1 > 0 && res - 1 > res1)
                document.write(myArray[i] + "<BR>");
      }  
 
No comments:
Post a Comment