Guest User

Untitled

a guest
Jun 22nd, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. /w+@(tickets.)?company.com/i
  2.  
  3. findall(pattern, string, flags=0)
  4. Return a list of all non-overlapping matches in the string.
  5.  
  6. If one or more groups are present in the pattern, return a
  7. list of groups; this will be a list of tuples if the pattern
  8. has more than one group.
  9.  
  10. Empty matches are included in the result.
  11.  
  12. r'(w+@(tickets.)?company.com)'
  13. r'w+@(?:tickets.)?company.com'
  14.  
  15. '(w+@(?:tickets.)?company.com)'
  16.  
  17. r'w+@(tickets.)?company.com'
  18.  
  19. >>> import re
  20. >>> exp = re.compile(r'w+@(tickets.)?company.com')
  21. >>> bool(exp.match("s@company.com"))
  22. True
  23. >>> bool(exp.match("1234567@tickets.company.com"))
  24. True
  25.  
  26. #!/usr/bin/python
  27.  
  28. import re
  29.  
  30. regex = re.compile("(w+@(?:tickets.)?company.com)");
  31.  
  32. a = [
  33. "foo@company.com",
  34. "foo@tickets.company.com",
  35. "foo@ticketsacompany.com",
  36. "foo@compant.org"
  37. ];
  38.  
  39. for string in a:
  40. print regex.findall(string)
Add Comment
Please, Sign In to add comment