On Jul 19, 12:52 pm, Gordon Airporte <[EMAIL PROTECTED]> wrote: > 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) > if gotit: > gotit = gotit[0] > ...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 > anything slower.
if your search is not overly complicated, i think regexp is not needed. if you want, you can post a sample what you want to search, and some sample input. -- http://mail.python.org/mailman/listinfo/python-list