-2

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

foo user@google.com foo,

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

I want to get user@google.com, 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 aUser@example.com foo";
str = str.split(" ")[1];
console.log(str);
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79