<[EMAIL PROTECTED]> wrote:
> r=re.compile("a+")
> [m.start() for m in r.finditer(s) if len(m.group()) == 1]
>
< Mine runs 100K iterations of 'abcdatraataza','a' in 1.4s
> whereas Fredrik's does the same in 1.9s
sure, but how long did it take you to come up with a working RE? and how
many casual
On Tue, 14 Dec 2004 14:05:38 +0100, Franz Steinhaeusler
<[EMAIL PROTECTED]> wrote:
>given a string:
>
>st="abcdatraataza"
>^ ^ ^ ^ (these should be found)
>I want to get the positions of all single 'a' characters.
>(Without another 'a' neighbour)
>[...]
Thank you again, Pádraig and Stev
[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
import re
s='abcdatraataza'
r=re.compile('(?
Oops, tested this time:
import re
def index_letters(s,l):
regexp='(?
print index_letters('abcdatraataza','a')
Just comparing Fredrik Lundh's method:
r=re.compile("a+")
[m.
[EMAIL PROTECTED] wrote:
import re
s='abcdatraataza'
r=re.compile('(?
Oops, tested this time:
import re
def index_letters(s,l):
regexp='(?
print index_letters('abcdatraataza','a')
--
Pádraig Brady - http://www.pixelbeat.org
--
--
http://mail.python.org/mailman/listi
Franz Steinhaeusler wrote:
given a string:
st="abcdatraataza"
^ ^ ^ ^ (these should be found)
I want to get the positions of all single 'a' characters.
(Without another 'a' neighbour)
You could also try negative lookahead/lookbehind assertions:
>>> st="abcdatraataza"
>>> for m in re.findi
Franz Steinhaeusler wrote:
given a string:
st="abcdatraataza"
^ ^ ^ ^ (these should be found)
I want to get the positions of all single 'a' characters.
(Without another 'a' neighbour)
So I tried:
r=re.compile('[^a]a([^a]')
but this applies only for
the a's, which has neighbours.
So I
Franz Steinhaeusler wrote:
> given a string:
>
> st="abcdatraataza"
>^ ^ ^ ^ (these should be found)
> I want to get the positions of all single 'a' characters.
for m in re.finditer("a+", st):
if len(m.group()) == 1:
print m.start()
or, perhaps:
indexes = [m.start() for m i
given a string:
st="abcdatraataza"
^ ^ ^ ^ (these should be found)
I want to get the positions of all single 'a' characters.
(Without another 'a' neighbour)
So I tried:
r=re.compile('[^a]a([^a]')
but this applies only for
the a's, which has neighbours.
So I need also '^a' and 'a$'.
On Tue, 14 Dec 2004 14:19:35 +0100, "Fredrik Lundh"
<[EMAIL PROTECTED]> wrote:
>Franz Steinhaeusler wrote:
>> given a string:
>>
>> st="abcdatraataza"
>>^ ^ ^ ^ (these should be found)
>> I want to get the positions of all single 'a' characters.
>
>for m in re.finditer("a+", st):
>if
On Tue, 14 Dec 2004 14:05:38 +0100, Franz Steinhaeusler
<[EMAIL PROTECTED]> wrote:
sorry
>r=re.compile('[^a]a([^a]')
r=re.compile('[^a]a[^a]')
I meant.
--
Franz Steinhaeusler
--
http://mail.python.org/mailman/listinfo/python-list
10 matches
Mail list logo