Why I need to use reg-ex if I can use for loops s = "Please contact [email protected] for assistance" email = [i for i in s.split(' ') if '@' in i]
cause in other cases you can have @ symbol in no email words forma example. Regular expressions can specify a more complex email format, analysing all the components in an email, not only that it has an @
No. There was another name on that response earlier; it switched around 13:00 UTC. That answer also has a typo; it needs a \ for the 2nd 'w'.
I understand trouble with for loop, but also you have mistake. If we have sample like this: s= 'Sasha Veledzimovich [email protected], [email protected], [email protected]' You code will provide e-mail with dot at the end. We can fix it pat=r"[\w\.-][email protected][w\.-]+\.[\w]+" Also you have parenthesis. They are not nessessary. If we use re.findall we have emails separated by groups. For example : ('python', 'gmail.url', '.com')
Did you just answer your own question like it was to somebody else?
Error in Program