Is it possible to pass variable to regex?
let name = "John";
let regex = /<&.*<--name-->.*&>/g;
let string = string.repace(regex, value);
How can I correct pass "John"
to regex?
Is it possible to pass variable to regex?
let name = "John";
let regex = /<&.*<--name-->.*&>/g;
let string = string.repace(regex, value);
How can I correct pass "John"
to regex?