I have an array of email addresses:
var emails = ['[email protected]', '[email protected]', '[email protected]']
I have a regular expressions to strip the last name from the emails:
var re = /(?<=[.]).*(?=[\@])/g; //Strips last name from email address.
I am trying to strip the last name and create a new array with those so it would look like:
[last, lst, name]
Here is the code I have tried, but it is not parsing out the last name at all and is just printing out the first and last email address. Any ideas on how I can achieve this? Thanks!
function onEdit() {
var re = /(?<=[.]).*(?=[\@])/g;
var emails = ['[email protected]', '[email protected]', '[email protected]']
const matchVal = emails.filter(value => re.test(value));
Logger.log(matchVal);
}
//Result of above function
//[[email protected], [email protected]]