Reputation: 1207
I need to match such thing:
pid = '0000000001'
redirectUrlMatch = /https:\/\/example.com\/products\/.*?\/pages\/(pid)\/redirect\/(pid)/
assert.equal validator.matches(html, redirectUrlMatch), true
But it fails, because how I think pid
cant be placed to regex
How I can perform this?
Upvotes: 0
Views: 222
Reputation: 1212
seems you want put pid into the regex as below
/https:\/\/example.com\/products\/.*?\/pages\/(0000000001)\/redirect\/(0000000001)/
you can do this way:
pid = '0000000001'
var redirectUrlMatch = new RegExp("https:\/\/example.com\/products\/.*?\/pages\/("+pid+")\/redirect\/("+pid+")");
Upvotes: 1