Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- re.findall failing for regex with grouping in Python
- pat = "[w]+[ ]*@[ ]*[w]+.[w]+"
- re.findall(pat, 'abc@cs.stansoft.edu.com .rtrt.. myacc@gmail.com ')
- ['abc@cs.stansoft', 'myacc@gmail.com']
- pat = "[w]+[ ]*@[ ]*[w]+(.[w]+)*"
- re.findall(pat, 'abc@cs.stansoft.edu.com .rtrt.. myacc@gmail.com ')
- ['.com', '.com']
- pat = "[w.]+ *@ *w+(?:.w+)*"
- re.findall(pat, 'abc@cs.stansoft.edu.com .rtrt.. myacc@gmail.com ')
- pat = '([w.-]+)@([w.-]+)'
- re.findall(pat, 'abc@cs.stansoft.edu.com .rtrt.. myacc@gmail.com ')
- [('abc', 'cs.stansoft.edu.com'), ('myacc', 'gmail.com')]
- emails = 'abc@cs.stansoft.edu.com .rtrt.. myacc@gmail.com '
- pat = '([w.-]+)@([w.-]+)'
- re.sub(pat, r'1@live.com', emails)
- 'abc@live.com .rtrt.. myacc@live.com '
- pat = '[w.-]+@[w.-]+'
- re.findall(pat, 'abc@cs.stansoft.edu.com .rtrt.. myacc@gmail.com ')
- ['abc@cs.stansoft.edu.com', 'myacc@gmail.com']
Add Comment
Please, Sign In to add comment