Guest User

naveen/pythonre_emailid

a guest
Jan 11th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. naveen@ol4:>python
  2. Python 2.7.5 (default, Sep 14 2016, 08:35:31)
  3. [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>>
  6. >>>
  7. >>>
  8. >>> line="my email id is naveen.polamreddi@gmail.com"
  9. >>> line1="my email id is sarath.storage@gmail.com"
  10. >>> line2="my email id is saradhi@gmail.com"
  11. >>> line3="santosh.akula@gmail.com is the email of santosh"
  12. >>> patter=r".+?\..+?\@.*"
  13. >>> pattern=r".+?\..+?\@.*"
  14. >>> import re
  15. >>> data=re.findall(pattern,line,re.I)
  16. >>> data
  17. ['my email id is naveen.polamreddi@gmail.com']
  18. >>> line="my email id is naveen.polamreddi@gmail.com"
  19. >>> pattern=r"(\w+\.\w+\@\w+\.\w+)"
  20. >>> data=re.findall(pattern,line,re.I)
  21. >>> data
  22. ['naveen.polamreddi@gmail.com']
  23. >>> data3=re.findall(pattern,line3,re.I)
  24. >>> data3
  25. ['santosh.akula@gmail.com']
  26. >>> data1=re.findall(pattern,line1,re.I)
  27. >>> data1
  28. ['sarath.storage@gmail.com']
  29. >>> data2=re.findall(pattern,line2,re.I)
  30. >>> data2
  31. []
  32. >>> line2
  33. 'my email id is saradhi@gmail.com'
  34. >>> pattern
  35. '(\\w+\\.\\w+\\@\\w+\\.\\w+)'
  36. >>> line2
  37. 'my email id is saradhi@gmail.com'
  38. >>> pattern2=r"(\w+\@.+)"
  39. >>> data2=re.findall(pattern2,line2,re.I)
  40. >>> data22
  41. Traceback (most recent call last):
  42. File "<stdin>", line 1, in <module>
  43. NameError: name 'data22' is not defined
  44. >>> data2
  45. ['saradhi@gmail.com']
  46. >>>
Add Comment
Please, Sign In to add comment