-2

I would like to get everything after and before the @ in a string. For example, the string:

foo [email protected] foo,

I would like to get the whole string before @ and after the @. Thank you in advance

I want to get [email protected], and remove foo and foo from the string using the @

Aiden Kaiser
  • 155
  • 1
  • 9

1 Answers1

0

Just use String.prototype.split() like this:

var str = "foo [email protected] foo";
str = str.split(" ")[1];
console.log(str);
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79