Matching Control Characters

Greg Lindstrom greg.lindstrom at
Mon Nov 1 17:24:47 CET 2004


I have a text file generated on a HP-9000 running HP-Unix with embedded
control characters and would like to read it in, modify it, and write it out
in PDF format.  The new page character is control-L which I can match with
regular expressions as

/^M    (build using control-Q control-M)

but when I attempt to use this to match the string in the program using

if re.match('^M', input_line):    # using control-Q control-M
   # issue a page feed

it will not match (no new pages are generated).

I am opening and reading the input file in binary mode.  Anyone see what I'm
doing wrong?


Greg Lindstrom                                         (501) 975-4859
NovaSys Health                  greg.lindstrom at

"We are the music makers, and we are the dreamers of dreams"  W.W.

More information about the Python-list mailing list