Matching Control Characters

G

Greg Lindstrom

Hello-

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?

Thanks!
--greg



Greg Lindstrom (501) 975-4859
NovaSys Health (e-mail address removed)

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

Reinhold Birkenfeld

Greg said:
Hello-

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?

Use the escape for Control-M: \x0D

Reinhold
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Matching Control Characters 1
Pattern Matching 0
Sharing Base Class members 0
Looking for Form Feeds 2
Machine identification 1
Oracle Access via cx_Oracle 0
Oracle Access via cx_Oracle 1
Boa Constructor Problem 5

Members online

No members online now.

Forum statistics

Threads
473,888
Messages
2,569,964
Members
46,294
Latest member
HollieYork

Latest Threads

Top