I'm trying to modify a string with a piece of javascript, but I'd like to include a the value of a variable in a search string. I have it set up something like this:
var checkFor = /\d/;
var replaceString = 'replacewiththis';
var postRegex = myString.replace(checkFor, replaceString);
The code above works just fine for just looking for digits, but things break down if I try to add the value of a variable, i.e.,
var checkFor = /\d/ + myVariable;
Does anyone know how to do this?
Thanks,
Alex
var checkFor = /\d/;
var replaceString = 'replacewiththis';
var postRegex = myString.replace(checkFor, replaceString);
The code above works just fine for just looking for digits, but things break down if I try to add the value of a variable, i.e.,
var checkFor = /\d/ + myVariable;
Does anyone know how to do this?
Thanks,
Alex