python regular expression repeating group matches
python, regex
Solution
You can use `re.findall` for this.
result = re.findall('\s\d+', x)
print result[1] # 2958
print result[3] # 3103
Problem
Possible Duplicate: Python regular expressions - how to capture multiple groups from a wildcard expression? I cannot access the group for 3rd or 5th element in the following regex: ``` >>> x = 'f 167 2958 335 3103 0' >>> re.search('.(\s\d+){5}', x).group() 'f 167 2958 335 3103 0' >>> re.search('.(\s\d+){5}', x).group(1) ' 0' >>> # how do i access no 2958 and 3103 ``` I know I can achieve the above with pattern = '.\s\d+\s(\d+)\s\d+\s(\d+)\s\d+', but thats lame. Thanks, Amit