Something confusing about non-greedy reg exp match

Ben Finney ben+python at benfinney.id.au
Mon Sep 7 00:23:34 EDT 2009


George Burdell <gburdell1 at gmail.com> writes:

> I want to find every occurrence of "money," and for each occurrence, I
> want to scan back to the first occurrence of "hello." How can this be
> done?

By recognising the task: not expression matching, but lexing and
parsing. For which you might find the ‘pyparsing’ library of use
<URL:http://pyparsing.wikispaces.com/>.

-- 
 \         “Science is a way of trying not to fool yourself. The first |
  `\     principle is that you must not fool yourself, and you are the |
_o__)               easiest person to fool.” —Richard P. Feynman, 1964 |
Ben Finney



More information about the Python-list mailing list