[Tutor] regexp help

Kent Johnson kent_johnson at skillsoft.com
Thu Sep 23 16:14:25 CEST 2004

I'm not sure what you are trying to do here. It would help to see a sample 
of input and output data.

If you are trying to process stdin by lines, maybe you want to use 
something like
for data in sys.stdin:
         # process one line...

The code you have will read all input from stdin and process it at once. 
The regex will match everything from the first --==--==--==--==-- to the 
last, even spanning many lines. Is that what you want?


At 04:18 PM 9/22/2004 +0200, Botykai Zsolt wrote:
>Hi for everyone,
>just dived in to regexp, and have some problem, wrote this script to work 
>as a
>pipe for multiline text input.
>My problem is
>- how to cut out all the empty lines (empty line: content only space or tab)
>from f_body?
>import sys
>import re
>data = sys.stdin.read()
>match_body = re.compile(
>         r"""--==--==--==--==--.(.+).--==--==--==--==--""",
>         re.DOTALL |
>         re.MULTILINE |
>         re.VERBOSE)
>f_body = match_body.search(data)
>f_body = match_body.search(data)
>o_output = f_body.group(0)
>Thx for any help,
>Zsoltik@ from Hungary
>(sorry about the disclaimer...)
>Opinions, conclusions and other information in this message that do not
>relate to the official business of Online Business Technologies Corp.
>shall be understood as neither given nor endorsed by it. In such cases
>Online Business Technologies Corp. will not bear the responsibility of
>If you have received this communication in error, please notify the
>system manager immediately by responding to this email and then delete
>it from your system.
>A levelben foglalt, nem az Online Rt. hivatalos uzletmenetevel kapcsolatos
>velemenyek vagy mas informaciok vonatkozasaban az Online Rt. nem vallal
>Amennyiben a level valamely hiba folytan jutott Onhoz, kerjuk, hogy
>valaszlevelben azonnal ertesitse a rendszer uzemeltetojet, majd torolje ki
>a levelet rendszerebol!
>Tutor maillist  -  Tutor at python.org

More information about the Tutor mailing list