开发者

python regexp help

开发者 https://www.devze.com 2023-01-11 00:47 出处:网络
Good day. Little question about reg exp. I have a string look like http://servercom/s开发者_开发百科mth/Age=&Filter=2&

Good day. Little question about reg exp.

I have a string look like

http://servercom/s开发者_开发百科mth/Age=&Filter=2&

How can i cut & with regexp from url?

After regexp url-string must be http://server.com/smth/Age=1&Filter=2&


You don't need regex for that:

changed = str.replace('&', '&');

http://docs.python.org/library/string.html#string.replace


You are translating XML escaped special characters. Use the standard lib:

>>> u = "http://servercom/smth/Age=&Filter=2&
>>> import xml.sax.saxutils
>>> xml.sax.saxutils.unescape(u)
'http://servercom/smth/Age=&Filter=2&'
0

精彩评论

暂无评论...
验证码 换一张
取 消