正则表达式的问题
遇到一个问题。。在处理url时,希望能够修改“?”后面的许多参数中的某一个的值(如果存在提供的那个key的话,就修改,如果不存在,就添加)php中的一个例子:
<?php
$strs=array(
"/default/index/index/aa/1?xx=e&page=aa&asaa=dd",
"/default/index/index/aa/1?page=aa&asaa=dd",
"/default/index/index/aa/1?page=aa",
"/default/index/index/aa/1/?xx=e&page=aa&asaa=dd",
"/default/index/index/aa/1/?page=aa&asaa=dd",
"/default/index/index/aa/1/?page=aa",
"/default/index/index/page/1/?xx=e&pages=aa&asaa=dd",
"/default/index/index/page/1/?pages=aa&asaa=dd",
"/default/index/index/page/1/?pages=aa",
"/default/index/index/aa/nn/page/1/",
"/default/index/index/page/1/",
"/default/index/index/page/1",
"/default/index/index/aa/bb/page/1"
);
$attrs['pageno']="page";
$pageno=33;
foreach($strs as $str)
echo preg_replace(
"/(\/\w+\/\w+\/\w+(\/\w+)*\/?)(\?|(\?\w+=[^&]+)*\&|\/)".$attrs['pageno']."([=\/])\w+/i",
"\$1\$3".$attrs['pageno']."\${5}".$pageno,
$str
)."\n";
?>
c#中该怎么写?谢谢