With javascript, how do we remove the @gmail.com or @aol.com from a string so that what only remains is the name? 

```
var string = "johndoe@yahoo.com";

```

Will be just "johdoe"? I tried with split but it did not end well. thanks.
['https://Stackoverflow.com/questions/18371339', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2522342/']
```
var email = "johndoe@yahoo.com";
email=email.replace(/@.*/,""); //returns string (the characters before @)

```
This simple regex will do the needful.  

`/^.*(?=@)/g`.

Example:

```
"johndoe@yahoo.com".match(/^.*(?=@)/g); // returns Array [ "johndoe" ]

```