H
Hans
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":Traceback (most recent call last):
thanks!!!
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":Traceback (most recent call last):
thanks!!!