Re: Finding all regex matches by index?
- From: Roy Smith <roy@xxxxxxxxx>
- Date: Tue, 29 May 2012 21:49:23 -0400
In article <roy-ACBB94.21332929052012@xxxxxxxxxxxxxx>,
Roy Smith <roy@xxxxxxxxx> wrote:
I have a long string (possibly 100s of Mbytes) that I want to search for
regex matches. re.finditer() is *almost* what I want, but the problem
is that it returns matching strings. What I need is a list of offsets
in the string where the regex matched. Thus:
s = "this is a string"
find("is", s) => [2, 5]
Is there anything that does this?
Ugh, looks like I simply mis-read the docs. findall() returns strings,
finditer() returns match objets (which is what I need). Duh.
.
- References:
- Finding all regex matches by index?
- From: Roy Smith
- Finding all regex matches by index?
- Prev by Date: Finding all regex matches by index?
- Next by Date: Re: Python 2.7.3, C++ embed memory leak?
- Previous by thread: Finding all regex matches by index?
- Index(es):
Relevant Pages
|