Best way to match everything between tags

Henning VON ROSEN hvrosen at world-online.no
Wed Jan 31 17:46:17 EST 2001


Hi!
I am learning regular expressions.

What is thenatural way to match everything that is not "something"
fx i want to maipulate all the text of a html document, but none of the tags


This matches all the tags;

s="text<body>some text<tag>more text</tag>text"
r = re.compile(r"<.*?>")
 print r.sub("WWW",s)

this works fine if I want to manipulate the tags, but I want to maipulate
the text between tags

I haven't found a one-expression way. Thankful for any indications!

/Henning von Rosen





More information about the Python-list mailing list