Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> z="this is x and this is x and also this is x and x x"
- >>> m = re.search('(x+)',z)
- >>> m.group(0,1)
- ('x', 'x')
- >>> m.group(2)
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- IndexError: no such group
- >>> m = re.search('(x)',z)
- >>> m.group(0,1)
- ('x', 'x')
- >>> m.group(2)
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- IndexError: no such group
- >>> m = re.search(r'(x)',z)
- >>> m.group(0,1)
- ('x', 'x')
- >>> m.group(2)
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- IndexError: no such group
Add Comment
Please, Sign In to add comment