Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- naveen@ol4:>python
- Python 2.7.5 (default, Sep 14 2016, 08:35:31)
- [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
- Type "help", "copyright", "credits" or "license" for more information.
- >>>
- >>>
- >>>
- >>> line="my email id is naveen.polamreddi@gmail.com"
- >>> line1="my email id is sarath.storage@gmail.com"
- >>> line2="my email id is saradhi@gmail.com"
- >>> line3="santosh.akula@gmail.com is the email of santosh"
- >>> patter=r".+?\..+?\@.*"
- >>> pattern=r".+?\..+?\@.*"
- >>> import re
- >>> data=re.findall(pattern,line,re.I)
- >>> data
- ['my email id is naveen.polamreddi@gmail.com']
- >>> line="my email id is naveen.polamreddi@gmail.com"
- >>> pattern=r"(\w+\.\w+\@\w+\.\w+)"
- >>> data=re.findall(pattern,line,re.I)
- >>> data
- ['naveen.polamreddi@gmail.com']
- >>> data3=re.findall(pattern,line3,re.I)
- >>> data3
- ['santosh.akula@gmail.com']
- >>> data1=re.findall(pattern,line1,re.I)
- >>> data1
- ['sarath.storage@gmail.com']
- >>> data2=re.findall(pattern,line2,re.I)
- >>> data2
- []
- >>> line2
- 'my email id is saradhi@gmail.com'
- >>> pattern
- '(\\w+\\.\\w+\\@\\w+\\.\\w+)'
- >>> line2
- 'my email id is saradhi@gmail.com'
- >>> pattern2=r"(\w+\@.+)"
- >>> data2=re.findall(pattern2,line2,re.I)
- >>> data22
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- NameError: name 'data22' is not defined
- >>> data2
- ['saradhi@gmail.com']
- >>>
Add Comment
Please, Sign In to add comment