Seeking regex optimizer
Kay Schluehr
kay.schluehr at gmx.net
Mon Jun 19 05:06:43 EDT 2006
Mirco,
with "special characters" I mentioned control characters of regular
expressions i.e. one of ".^$()?[]{}\|+*" but not non ascii-127
characters.
For a workaround you simply have to "mangle" those using an escape
control character:
REGEXCHAR = ".^$()?[]{}\\|+*"
def mangle(s):
pattern = []
for c in s:
if c in REGEXCHAR:
pattern.append("\\")
pattern.append(c)
return "".join(pattern)
Regards,
Kay
More information about the Python-list
mailing list