str = "{u'xlink:href': u'http://ip/goform/XmlApi?op=ip&port=0&target=1', u'id': u'1'}"
print re.search("/href': u'.*?',/", str)
I'm trying to get the text that starts with http:// and ends with target=1 but I'm getting None. Is my regex wrong?
str = "{u'xlink:href': u'http://ip/goform/XmlApi?op=ip&port=0&target=1', u'id': u'1'}"
print re.search("/href': u'.*?',/", str)
I'm trying to get the text that starts with http:// and ends with target=1 but I'm getting None. Is my regex wrong?
Yes I think you're searching for the wrong thing (if what you want is the url):
#!/usr/bin/env python
import re
if __name__ == '__main__':
s = "{u'xlink:href': u'http://ip/goform/XmlApi?op=ip&port=0&target=1', u'id': u'1'}"
m = re.search(r"u'(http://.*?)',", s)
print m.group(1)