Hi everyone!
How can I simply search text for regexps (lets say <a
href="(.*?)">(. *?)</a>) and save all URLs(1) and link contents(2) in a
dictionary { name : URL}? In a single pass if it could.
Or how can I replace the html &entities; in a string
"blablabla& blablabal&b albalbal" with the chars they mean using
re.sub? I found out they are stored in an dict [from htmlentitydefs import
htmlentitydefs]. I though about this functionality:
regexp = re.compile("&[a-zA-Z];")
regexp.sub(enti tydefs[r'\1'], url)
but it can't work, because the r'...' must eaten directly by the sub, and
cannot be used so independently ( at least I think so). Any ideas? Thanks
in advance.
-i
---------------------------------------_.)--
| Lukas Holcik (xholcik1@fi.mu ni.cz) (\=)*
----------------------------------------''--
How can I simply search text for regexps (lets say <a
href="(.*?)">(. *?)</a>) and save all URLs(1) and link contents(2) in a
dictionary { name : URL}? In a single pass if it could.
Or how can I replace the html &entities; in a string
"blablabla& blablabal&b albalbal" with the chars they mean using
re.sub? I found out they are stored in an dict [from htmlentitydefs import
htmlentitydefs]. I though about this functionality:
regexp = re.compile("&[a-zA-Z];")
regexp.sub(enti tydefs[r'\1'], url)
but it can't work, because the r'...' must eaten directly by the sub, and
cannot be used so independently ( at least I think so). Any ideas? Thanks
in advance.
-i
---------------------------------------_.)--
| Lukas Holcik (xholcik1@fi.mu ni.cz) (\=)*
----------------------------------------''--
Comment