문제

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)) {


}
도움이 되었습니까?

해결책

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
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top