Extract all email addresses from bulk text using jquery

前端 未结 7 1534
北海茫月
北海茫月 2020-11-28 06:09

I\'m having the this text below:

sdabhikagathara@rediffmail.com, \"assdsdf\" , \"rodnsdfald ferdfnson\" 

        
7条回答
  •  遥遥无期
    2020-11-28 06:39

    Here's how you can approach this:

    HTML

    JavaScript

    var text = 'sdabhikagathara@rediffmail.com, "assdsdf" , "rodnsdfald ferdfnson" , "Affdmdol Gondfgale" , "truform techno" , "NiTsdfeSh ThIdfsKaRe" , "akasdfsh kasdfstla" , "Bisdsdfamal Prakaasdsh" ,; "milisdfsfnd ansdfasdfnsftwar" ';    
    
    function extractEmails (text)
    {
        return text.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
    }
         
    $("#emails").text(extractEmails(text).join('\n'));
    

    Result

    sdabhikagathara@rediffmail.com dsfassdfhsdfarkal@gmail.com rfernsdfson@gmal.com gyfanamosl@gmail.com pidfpinfg@truformdftechnoproducts.com nthfsskare@ysahoo.in akashkatsdfsa@yahsdfsfoo.in bimsdaalprakash@live.com dfdmilifsd.ensfdfcogndfdfatia@gmail.com
    

    Source: Extract email from bulk text (with Regular Expressions, JavaScript & jQuery)

    Demo 1 Here

    Demo 2 Here using jQuery's each iterator function

提交回复
热议问题