I was wondering if is possible to transform a string into an array using Arrow Function:
var str = 'Bob@example.com;Mark@example.com,robert@email.com';
var result = str.split(';').map(e => e.split(','))
//desired result: {VALUE: 'Bob@example.com'},
// {VALUE: 'Mark@example.com},
// {VALUE: 'robert@email.com'}
You could split with a character class of comma and semicolon and map objects.
const
str = 'Bob@example.com;Mark@example.com,robert@email.com',
result = str
.split(/[,;]/)
.map(VALUE => ({ VALUE }));
console.log(result);
.as-console-wrapper { max-height: 100% !important; top: 0; }
You could use a regular expression to handle this
var str = 'Bob@example.com;Mark@example.com,robert@email.com';
var result = str.split(/[;,]/)
console.log(result);