Hi,

I'm doing a regular expression matching, let's say 
"a=re.search(re_str,match_str)", if matching, I don't know how many str/item 
will be extracted from re_str, maybe a.group(1), a.group(2) exist but 
a.group(3) does not. 

Can I somehow check it? something like:
if exist(a.group(1)): print a.group(1)
if exist(a.group(2)): print a.group(2)
if exist(a.group(3)): print a.group(3)


I don't want to be hit by "Indexerror":
>>>print a.group(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: no such group
>>> 

thanks!!!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to