How I could set the variable pat
to act as variable patt1
? I want write in the textbox just "abe" and change from var patt1 = /\b[abc]+\b/g;
to var patt1 = /\b[abe]+\b/g;
. Is that possible?
<html>
<body onload="onload();">
<input type="text" id="lol"/>
<input type="button" VALUE="Resitve" onclick="myFunction();"/>
<p id="alert"></p>
<script>
var pat;
function myFunction() {
pat = document.getElementById("lol").value;
var str = "abc ab abe abeee";
var patt1 = /\b[abc]+\b/g;
var result = str.match(pat);
document.getElementById("alert").innerHTML = result;
}
</script>
</body>
</html>