javascript - Get an email from a string -


a newbie here

this problem

let string

var string = "this string contains many different words domain@gmail.com want email"; 

what want regex or different gets domain@gmail.com

i've tried many things none has worked

this last 1 i've tried

var myregexp = /@(.*)/; var match = myregexp.exec(string); if(match)   console.log(match[1]); 

this returns null or undefined

can me out

edit

i want search before , after @ , stops on blank space

thanks

emails = str.match(/(\s[^\s@]*@\s+)/gi) 

Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -