[Tutor] Python re without string consumption
carroll at tjc.com
Fri Jan 26 01:44:29 CET 2007
On Thu, 25 Jan 2007, Jacob Abraham wrote:
> I would like to thank you for the solution and
> the helper funtion that I have written is as follows.
That's very similar to a solution I coded up for a friend, who was doing
searches in genetic sequences, and had exactly the same problem you did.
def myfindall(regex, seq):
result = regex.search(seq, pos)
if result is None:
pos = result.start()+1
>>> print myfindall(rexp,sequence)
['BAB', 'BEB', 'BIB']
> But I do hope that future versions of Python include a regular
> expression syntax to handle such cases...
My tongue-in-cheek recommendation was that re.findall be renamed to
More information about the Tutor