The goal is to replace digits 0-9 as well as a variable value from a text input in a form, with a substitute value of x if a match is found, as user types, using javascript.
Why does this not work?
regexExpression = "([0-9]" + companyvalue + ")"; 
Each case works when coded independently but does not work when concatenated.
var regexExpression = ("[0-9]"); Works as expected and substitutes x for numeric value.
var regexExpression = "("companyvalue")"; Works as expected and substitutes x for the variable text input value.
function clean(e) {
 var companyvalue = document.getElementById("company").value;
 var textfield = document.getElementById(e);
 var regexExpression = ('([0-9]' + companyvalue + ')');
 var regex = new RegExp(regexExpression,"g","i");
  if(textfield.value.search(regex) > -1) {
  document.getElementById('status').innerHTML = "Telephone numbers and company name<br>are automatically redacted.";
 }
 textfield.value = textfield.value.replace(regex, "x");
 //alert (companyvalue);
 }<input id="company" style="border-color:#F8980F;" class="medium required" type="text" name="company" />
<textarea id="description" onkeyup="clean('description')" onkeydown="clean('description')" class="medium" cols="25" rows="8" name="description" placeholder="Write a short summary." /></textarea>
<div id="status"></div> 
     
    