I have the variable label
const label = 'test'
and the regex
{ name: /test/i }
What I want is know if I can use the variable label inside the regex, something like this
label
{ name: `/${label}/i` }
Is it possible?
To use variable in regex, use:
new RegExp(`${label}`, 'i')
1.4m articles
1.4m replys
5 comments
57.0k users