Guest User

Untitled

a guest
Jan 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. >>> z="this is x and this is x and also this is x and x x"
  2. >>> m = re.search('(x+)',z)
  3. >>> m.group(0,1)
  4. ('x', 'x')
  5. >>> m.group(2)
  6. Traceback (most recent call last):
  7. File "<stdin>", line 1, in <module>
  8. IndexError: no such group
  9.  
  10.  
  11. >>> m = re.search('(x)',z)
  12. >>> m.group(0,1)
  13. ('x', 'x')
  14. >>> m.group(2)
  15. Traceback (most recent call last):
  16. File "<stdin>", line 1, in <module>
  17. IndexError: no such group
  18.  
  19. >>> m = re.search(r'(x)',z)
  20. >>> m.group(0,1)
  21. ('x', 'x')
  22. >>> m.group(2)
  23. Traceback (most recent call last):
  24. File "<stdin>", line 1, in <module>
  25. IndexError: no such group
Add Comment
Please, Sign In to add comment