trying to find repeated substrings with regular expression

Giovanni Bajo raNOsky at deveSPAMler.com
Mon Mar 13 19:41:38 CET 2006


Robert Dodier wrote:

> Hello all,
>
> I'm trying to find substrings that look like 'FOO blah blah blah'
> in a string. For example give 'blah FOO blah1a blah1b FOO blah2
> FOO blah3a blah3b blah3b' I want to get three substrings,
> 'FOO blah1a blah1b', 'FOO blah2', and 'FOO blah3a blah3b blah3b'.

> [...]

> Can someone suggest a regular expression which will return
> groups corresponding to the FOO substrings above?

FOO.*?(?=(?:FOO|$))
-- 
Giovanni Bajo





More information about the Python-list mailing list