Pergunta

How to compare parameter pattern to URL parameters by native JavaScript?

For example my cache value is __/v1/abc/abcd/?lat=40.12323&lon=2.1342&radius=1&x=gdfgdf

I'd like to compare this regex pattern lat=[*]&lon=[*]&radius=[*] to above cache value:

Does my cache include this challenge?

if (cache.regex(abovepattern)) {


}
Foi útil?

Solução

var cache="__/v1/abc/abcd/?lat=40.12323&lon=2.1342&radius=1&x=gdfgdf";


if(cache.match(/lat=([-+]?\d+\.\d+)&lon=([-+]?\d+\.\d+)/))
{
      // Your Code Match
}
else
{
      // Your Code On Not Match
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top