I need to parse an arithmetic string with only *times* (`*`) and *add* (`+`), e.g., `300+10*51+20+2*21`, use regular expressions. 

I have the working code below: 

```
import re

input_str = '300+10*51+20+2*21'

#input_str = '1*2+3*4'

prod_re = re.compile(r"(\d+)\*(\d+)")
sum_re = re.compile(r"(\d+)\+?")

result = 0
index = 0
while (index <= len(input_str)-1):
    #-----
    prod_match = prod_re.match(input_str, index)
    if prod_match:
        # print 'find prod', prod_match.groups()
        result += int(prod_match.group(1))*int(prod_match.group(2))
        index += len(prod_match.group(0))+1
        continue
    #-----
    sum_match = sum_re.match(input_str, index)
    if sum_match:
        # print 'find sum', sum_match.groups()
        result += int(sum_match.group(1))
        index += len(sum_match.group(0))
        continue
    #-----
    if (not prod_match) and (not sum_match):
        print 'None match, check input string'
        break

print result

```

I am wondering if there is a way to avoid creating the variable `index` above?