문제

I would like to use the regular expressions in Python to get everything that is after a </html> tag, an put it in a string. So I tried to understand how to do it in Python but I was not able to make it work. Can anyone explain me how to do this ridiculous simple task ?

도움이 되었습니까?

해결책

m = re.match(".*<\html>(.*)",my_html_text_string)
print m.groups()

or even better

print my_html_string.split("</html>")[-1]

다른 팁

You can do this without a regular expression:

text[text.find('</html>')+7:]
import re

text = 'foo</html>bar'
m = re.search('</html>(.*)', text)
print m.group(1)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top