This topic created in 3465 days ago, the information mentioned may be changed or developed.
有 url=> /tst/req.php?szID=123&tst=&szPass=s123&szLimit=20&szInf=test
参数都有可能为空,想要改为例如:
/tst/req.php?szID=123A&tst=A&szPass=s123A&szLimit=20A&szInf=testA
想用正则表达式修改参数值,前方参照([\?&][a-zA-Z]+?\=)后,参数值不知如何取
5 replies • 2016-12-01 11:07:18 +08:00
 |
|
1
SilentDepth Dec 1, 2016 1
/&([a-z]+)(?:=([^&]+)?)?/i 这样?
|
 |
|
2
whahugao Dec 1, 2016 1
```php $s = '/tst/req.php?szID=123&tst=&szPass=s123&szLimit=20&szInf=test'; $ss = preg_replace('/([\?&][a-zA-Z]+)([^&]*)/','\1\2A',$s); ```
|
 |
|
4
mooncakejs Dec 1, 2016 1
php 的话不如 parse_url 何必这么辛苦
|
 |
|
5
sunhk25 Dec 1, 2016
@ mooncakejs 这个挺方便的,我用的是 c#,查了下有这个函数 ParseQueryString 跟 parse_url 差不多
|