[FRPythoneers] Porting 1.5.2 regex to 2.2.x re

Erick Bodine erick at allocity.com
Fri Jun 6 16:10:56 MDT 2003


I am by no means an regular expression expert but I am having trouble
porting an older python (1.5.2) script that I did not write to 2.2.x

This is the 1.5.2 code and the returned list:

tokens = regsub.splitx(formLine, "[@\^]\([|<>*#]\)\\1*\(\\1\|\.\)?\\1*")
print tokens

['===', '@<<<<<<<<', '====', '@>>>>>>>>>>>', '====', '@||||||||||||',
'====', '@
####.##', '===.', '^<<<<<<<<<<<<<<<<', '']

This is what I have for 2.2.x

tokens = re.split("[@\^]\([|<>*#]\)\1*\(\1\|\.\)?\1*", formLine)
print tokens

['===@<<<<<<<<====@>>>>>>>>>>>====@||||||||||||====@####.##===.^<<<<<<<<
<<<<<<<<
']

Obviously I would prefer that the later code return a list of same form
that the older code does but I am having an incredible time making it do
just that.

--ERick



More information about the FRPythoneers mailing list