我的字符串是
"http://exanmple.com/katalogas/?is_search=1&type=list&filter=search_1&activity=&activity_id=&activity=langai&activity_id=®ion_id=-2&page_no=2"
我希望从字符串替换所有page_no=2
号码都可以更改,短语是静态的page_no
我尝试了什么:
/\&page_no=[0-9]\b/i
答案 0 :(得分:1)
您可以匹配此正则表达式:
/(?<=\?)page_no=\d+&|&page_no=\d+\b/i
<强>代码:强>
$url = preg_replace('/(?<=\?)page_no=\d+&|&page_no=\d+\b/i', '', $url);