JSFiddle - React, Tailwind, and code Playground
HTML
<input id="email" name="email" type="text" />
JavaScript
function validate() {
data = "foo bar [email protected], foo baz [email protected],foo foo [email protected],[email protected] , bar baz [email protected]";
email_data = data.split(','); // This will get the all data spliting by ','
for (i = 0; i < email_data.length; i++) {
console.log(email_data[i].match(/[\w._+-]+@[\w._+-]+\.[\w]{2,6}/));
}
}
validate();