python regexp help
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&'
精彩评论