Regular expression

Peter Fodrek peter.fodrek at stuba.sk
Tue Jul 21 15:30:47 CEST 2009


Dear conference!

I have  third party regular expression

 self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d+|\(.*?\)|
\#\d+\=(?:[+])?\d*(?:\.\d*)?)')

with code

 def readline(self):
        self.line = self.file_in.readline().rstrip()  
	if (len(self.line)) : return True
        else : return False

 while (self.readline()):
            words = self.pattern_main.findall(self.line)


This handles text file  like

// remark
PL_OFF
PARK
FS
MA  52.8806 ,  18.0914
SS
AD_W
PL_ON
C   52.3955 ,  -16.1511 ,  -90.0000

It handles file correctly with two exceptions

1) omits ',' in the a output
2) omits minus sign in the numbers...

Would anyone recommend me what to change regular expression to add thesee two 
think to the output,please?

Thank you for any help.

I  look forward hearing form you
Yours faithfully

Peter Fodrek
 



More information about the Python-list mailing list