Extracting repeated words

candide candide at free.invalid
Sat Apr 2 15:18:03 CEST 2011


Le 02/04/2011 00:42, Ian Kelly a écrit :

> You could use a look-ahead assertion with a captured group:
>
>>>> regexp = r'\b(?P<dup>\w+)\b(?=.+\b(?P=dup)\b)'
>>>> c = re.compile(regexp, re.IGNORECASE | re.DOTALL)
>>>> c.findall(text)

It works fine, lookahead assertions in action is what exatly i was 
looking for, many  thanks.



More information about the Python-list mailing list