Guest User

Untitled

a guest
Jun 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. pattern = "(([ef]|([gh]d*(ad*[gh]d)*b))d*b([ef]d*b|d*)*c)"
  2.  
  3. matches = re.finditer(pattern, string)
  4. for match in matches:
  5. print "(%d-%d): %s" % (match.start(), match.end(), match.group())
  6.  
  7. Traceback (most recent call last):
  8. File "code.py", line 133, in <module>
  9. main(sys.argv[1:])
  10. File "code.py", line 106, in main
  11. for match in matches:
  12. KeyboardInterrupt
  13.  
  14. ddddddeddbedddbddddddddddddddddddddddddddddddddddd
  15.  
  16. ddddddeddbedddbdddddddddddddddddddddddd
  17.  
  18. ddddddeddbedddbdddddddddddddd
  19.  
  20. ([ef]|([gh]d*(ad*[gh]d)*b))d*b
  21.  
  22. |
  23.  
  24. (([ef]|([gh]d*(ad*[gh]d)*b))d*b([ef]d*b|d*)*c)
  25.  
  26. (([ef]|([gh]d*(ad*[gh]d)*b))d*b([ef]d*bd*)*c)
  27.  
  28. import re
  29.  
  30. string = "ddddddeddbedddbddddddddddddddddddddddddddddddddddd"
  31. pattern = "(([ef]|([gh](a[gh])*b))b([ef]b)*c)"
  32. matches = re.finditer(pattern, re.sub("d+", "", string))
  33. for match in matches:
  34. print "(%d-%d): %s" % (match.start(), match.end(), match.group())
Add Comment
Please, Sign In to add comment