I want to check if a string-variable (called string) matches the following string: L-62000-64-000_0
My code looks like this:
let string = "L-62000-64-000_05641";
let part = 64;
const filter = new RegExp("^L-\d{5}-${part}-.+");
if (string.match(filter)) {
console.log("yes");
}
It is important, that the string starts with "L-". After this there should be a number with five digits and again a hyphen. The following two digits depend on a variable. After the variable there is again a hyphen. The rest of the string is not important for me. That's why I use the ".+"
The problem is, that this doesn't work and i don't know why...