Possible Duplicate:
Javascript Regex: How to put a variable inside a regular expression?
I'm using the following for as regex pattnern in a sinon.js fakeServer response:
/https:\/\/ca-davstorage:8080\/myFile.json(\?.*|$)/
I would like to replace myFile
with a variable, but as I'm not really good at regex, I'm struggling to get it to work.
Currently I have this, but it does not seem to work.
'https:\\/\\/ca-davstorage:8080\\/'+myFile+'.json(\\?.*|$)/'
Question:
How to I correctly add a variable to a regex?
Thanks for help!