re.DOTALL
Wojtek Walczak
gminick at hacker.pl
Wed Nov 27 14:29:09 EST 2002
Dnia Wed, 27 Nov 2002 13:46:56 -0500, Irina Szabo napisał(a):
> What is wrong?
Nothing :) Your code works for me.
--- html.html ---
<html>
line 1
<head>
line 2
</head>
line 3
<body>
<!--
body { font-family: Arial, Helvetica, sans-serif; font-size: 10pt; color:
#000000}
-->
</body>
line 4
</html>
-----------------
--- py.py ---
import re
w = open("html.html")
a = w.read()
w.close()
matchstr = re.compile(r'''<.*?>''',re.DOTALL|re.MULTILINE)
print matchstr.sub(" ", a)
-------------
% python py.py
line 1
line 2
line 3
line 4
% _
Tested on Linux with:
% python -c "print getattr(__import__('sys'),'version')"
2.2.2 (#1, Oct 16 2002, 18:08:06)
[GCC 2.95.3 20010315 (release)]
% _
--
[ ] gminick (at) underground.org.pl http://gminick.linuxsecurity.pl/ [ ]
[ "Po prostu lubie poranna samotnosc, bo wtedy kawa smakuje najlepiej." ]
More information about the Python-list
mailing list