我有这样的URL结构:https://steamcommunity.com/tradeoffer/new/?partner=12a3456asdf789&token=12345Dasdew678
URL的两个参数partner
和token
将具有只能包含字母数字字符的动态值。
我想知道URL的格式是否符合我的要求
if($URLisFormattedProperly) {
return true;
} else {
return false;
}
我该怎么做?
现在,基于现有URL 的regex
preg_match('/https':'/'/steamcommunity'.com'/tradeoffer'/new'/'?partner=([a-zA-Z0-9]+)&token=([a-zA-Z0-9]+)/', $url, $matches);
if(count($matches)>0)
{
// this meets your criteria
}