I'm trying to match a URL which it can be generated with any random numbers, for example, these urls:
www.domain.com/products/id?=292
www.domain.com/products/id?=132
www.domain.com/products/id?=698
There a code to compare URL with random number is equal, this currently code won't work.
var url1= "www.domain.com/products/id?=292";
var url2= "www.domain.com/products/id?=7542";
var url3= "www.domain.com/products/id?=5401";
var numberPat = /[0-9]/;
if(url3 == "www.domain.com/products/id?=" + numberPat){
alert("Domain with random number is MATCHED")
}
else{
alert("Domain with random number is NOT matched")
}
I made a jsfiddle, http://jsfiddle.net/n5s2pvkr/1/ Im looking a solution that could return as true with matched url with random number
EDIT: I cannot accept url3.match(numberPat) for some reason, I need to do exactly like:
www.domain.com/products/id?=+numberPat due to selective comparison.