I have a regular expression and would like to put a variable inside it. How do I do?
My code is this:
public regexVariable(vRegex: string, testSentences: Array<any> ) {
const regex = new RegExp('/^.*\b(' + vRegex + ')\b.*$/');
const filterSentece = testSentences.filter(result => {
if (regex.test(result)) {
return result
})
}