JSFiddle - React, Tailwind, and code Playground

JavaScript

function doit(expression) {

    var regex = new RegExp(expression, 'g');

    alert(regex.test('[email protected]'));
}

doit("/^\w+([-+.\']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/");