J
jwwest
Anyone have any trouble pattern matching on lines returned by
readline? Here's an example:
string = "Accounting - General"
pat = ".+\s-"
Should match on "Accounting -". However, if I read that string in from
a file it will not match. In fact, I can't get anything to match
except ".*".
I'm almost certain that it has something to do with the characters
that python returns from readline(). If I have this in a file:
Accounting - General
And do a:
line = f.readline()
print line
I get:
A c c o u n t i n g - G e n e r a l
Not sure why, I'm a nub at Python so any help is appreciated. They
look like spaces to me, but aren't (I've tried matching on spacs too)
- james
readline? Here's an example:
string = "Accounting - General"
pat = ".+\s-"
Should match on "Accounting -". However, if I read that string in from
a file it will not match. In fact, I can't get anything to match
except ".*".
I'm almost certain that it has something to do with the characters
that python returns from readline(). If I have this in a file:
Accounting - General
And do a:
line = f.readline()
print line
I get:
A c c o u n t i n g - G e n e r a l
Not sure why, I'm a nub at Python so any help is appreciated. They
look like spaces to me, but aren't (I've tried matching on spacs too)
- james