I have an issue with dynamic regular expression. Here is the sample
var searchStr = "C:\\Users\\fds\\Desktop\\Node"
num = 2
var p ='([a-zA-Z]*:{1}(\\[a-zA-Z]*){'+num+'})'
var p1 = new RegExp(p,"gi")
console.log(p1)
let wabpath = searchStr.replace(p1,"")
console.log(wabpath)
I'm trying to pass the {num} dynamically but it's not working, Could anyone please help me on this?