29th Jul 2020, 10:30 AM
Mr. 12
Mr. 12 - avatar
4 Antworten
+ 3
Mr. 12 This is where lookarounds come in handy - they will match things that will not appear in the matched string. The regex '\S+(?=@)' will match a sequence of non-whitespace characters that appear immediately before the '@' symbol - (?=...) is the notation for a lookahead. And, '(?<=@)\S+' will match a sequence of non-whitespace characters that appear immediately after the '@' symbol - (?<=...) is the notation for a lookbehind. Hope that makes sense! https://code.sololearn.com/cc4XlRxT852Y/?ref=app
29th Jul 2020, 4:06 PM
Russ
Russ - avatar
+ 2
you could just split the mail string at the @ symbol. email, domain = "test123@gmail.com".split("@") print(email) print(domain) # output: test123 gmail.com
29th Jul 2020, 10:40 AM
Slick
Slick - avatar
0
yes bro, i know it. i am learning regex now. thats why i am using regex. i have already done this program without regex. https://code.sololearn.com/cCOlB1YA50j1/?ref=app
29th Jul 2020, 10:43 AM
Mr. 12
Mr. 12 - avatar
0
regex is more a search for a specific structured string. At most it should be used to replace certain characters. try making a regex for complete emails or even the youtube link finder in code coach!
29th Jul 2020, 10:50 AM
Slick
Slick - avatar