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

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -