reg exp and octal notation

Lucas Branca nospam at freeworld.fr
Fri Mar 5 09:15:34 EST 2004


Could someone explain me the difference between the results below?

## $cat octals.txt
## \006\034abc

import re

a= "\006\034abc"
preg= re.compile(r'([\0-\377]*)')
res = preg.search(a)
print res.groups()

loader = open('./octals.txt', 'r')
b = loader.readline()
preg= re.compile(r'([\0-\377]*)')
res = preg.search(b)
print res.groups()


RESULTS

('\x06\x1cabc',)

('\\006\\034abc\n',)


Many thanks
Lucas





More information about the Python-list mailing list