[Tutor] Regular Expressions part 2

Charlie Derr charlie@intelligenesis.net
Fri, 19 May 2000 19:00:52 -0400


I think you need to post your code.

I tried what you said and it worked for me:

>>> import re
>>> g = "bbbbbbkkdkdkdkdk"
>>> r = re.findall('b',g)
>>> type(r)
<type 'list'>
>>> r
['b', 'b', 'b', 'b', 'b', 'b']
>>> len(r)
6
>>> r[0]
'b'
>>>


|-----Original Message-----
|From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
|Brian Wisti
|Sent: Friday, May 19, 2000 6:46 PM
|To: tutor@python.org
|Subject: [Tutor] Regular Expressions part 2
|
|
|Hi all,
|
|Okay, so I figured out that re.findall() does a global search.  Well and
|good.
|
|Now I am on to a new strangeness.  Although I can print out the resulting
|list, and use "for item in matches" to step through the list, I cannot use
|array notation to access the list that results from a re.findall().
|
|For some strange reason, this thing that looks like an array (it
|even has a
|length of 2) tells me about "list index out of range" when I try to access
|matches[0].
|
|Umm... what am I missing now?
|
|Thanks,
|Brian Wisti
|bwisti@hotmail.com
|________________________________________________________________________
|Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
|
|
|_______________________________________________
|Tutor maillist  -  Tutor@python.org
|http://www.python.org/mailman/listinfo/tutor
|