idiom for RE matching
JHoover at fbi.gov
Thu Jul 19 06:52:48 CEST 2007
I have some code which relies on running each line of a file through a
large number of regexes which may or may not apply. For each pattern I
want to match I've been writing
gotit = mypattern.findall(line)
gotit = gotit
...do whatever else...
This seems kind of clunky. Is there a prettier way to handle this?
I've also been assuming that using the re functions that create match
objects is slower/heavier than dealing with the simple list returned by
findall(). I've profiled it and these matches are the biggest part of
the running time of the program, so I really would rather not use
More information about the Python-list