Stupid Regex Question
Jonas Galvez
jonas at jonasgalvez.com
Wed Apr 21 13:09:28 EDT 2004
But now I'm puzzled. What is that '?' doing, exactly?
Could you point me any references?
Thanks again,
=-
Jonas Galvez
jonasgalvez.com/blog
macromedia.com/go/team
> > [Fredrik Lundh]
> > print re.findall("<tag>(.*?)</tag>", str)
>
> WOW! Thanks a bunch (again).
>
> Hehe, I had already written the following:
>
> def getIndices(str, base):
> indices = []
> offset = 0
> while True:
> i = base.find(str, offset)
> if i == -1: break
> indices.append(i)
> offset = i+1
> return indices
>
> def getContent(a, b, str):
> content = []
> startIndices = getIndices(a, str)
> endIndices = getIndices(b, str)
> startSlice = len(a)
> def add(s, e):
> content.append(str[s+startSlice:e])
> map(add, startIndices, endIndices)
> return content
>
> Ouch.
>
>
>
>
>
> =-
> Jonas Galvez
> jonasgalvez.com/blog
> macromedia.com/go/team
More information about the Python-list
mailing list