Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. >>> #import regex library
  2. ... import re
  3. >>>
  4. >>> #use a regex to just get the numbers -- not the rest of the string
  5. ... matcht = re.findall(r'd', dwtunl)
  6. >>> matchb = re.findall(r'd', ambaas)
  7. >>> #macht = re.search(r'dd', dwtunl)
  8. ...
  9. >>> #just a test to see about my regex
  10. ... print matcht.group()
  11. Traceback (most recent call last):
  12. File "<stdin>", line 2, in <module>
  13. AttributeError: 'list' object has no attribute 'group'
  14. >>> print matchb.group()
  15. Traceback (most recent call last):
  16. File "<stdin>", line 1, in <module>
  17. AttributeError: 'list' object has no attribute 'group'
  18. >>>
  19. >>> #start defining the final variables
  20. ... if dwtunl == "No Delay":
  21. ... dwtunnl = 10
  22. ... else:
  23. ... dwtunnl = matcht.group()
  24. ...
  25. Traceback (most recent call last):
  26. File "<stdin>", line 5, in <module>
  27. AttributeError: 'list' object has no attribute 'group'
  28. >>> if ambaas == "No Delay":
  29. ... ammbaas = 10
  30. ... else:
  31. ... ammbaas = matchb.group()
  32. ...
  33. Traceback (most recent call last):
  34. File "<stdin>", line 4, in <module>
  35. AttributeError: 'list' object has no attribute 'group'
  36.  
  37. >>> import re
  38. >>> regex = re.compile(r"(w)(W)")
  39. >>> regex.findall("A/1$5&")
  40. [('A', '/'), ('1', '$'), ('5', '&')]
  41.  
  42. >>> for match in regex.finditer("A/1$5&"):
  43. ... print match.group(1), match.group(2)
  44. ...
  45. A /
  46. 1 $
  47. 5 &
  48.  
  49. for i in stored_list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement