substring and regular expression

Kent Johnson kent37 at
Thu Aug 4 15:35:31 CEST 2005

borges2003xx at wrote:
> i have read
> finding sublist
> the problem was in a string to find if we have two substring non
> overlapping of lenght al least 4
> it was done by
> r=re.compile(r'(?P<seq>.{4,}).*(?P=seq)')
> my knowhow on re is null
> there is a way in re for ask if a substring is the reverse of the
> otherone? First seq is second seq in reverse order

For a fixed-length substring you can use brute force. Here is a regex that matches a string containing a four-character substring and its reverse:

You might want to look at the Regular Expression HOW-TO document:


More information about the Python-list mailing list