Who solved this problem? i think there is a problem with fourth test? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Who solved this problem? i think there is a problem with fourth test?

https://code.sololearn.com/cMMAs8t73V8o/?ref=app

26th Jul 2021, 9:24 AM
Ашла Байке
Ашла Байке - avatar
3 Answers
+ 6
Ашла Байке , the task is much easier as it looks like. ▪︎for both variations of input format, always the last 11 characters of the strings are required. having this in mind, no regex is necessary.
26th Jul 2021, 10:06 AM
Lothar
Lothar - avatar
+ 3
the zen of python says: ▪︎Simple is better than complex ▪︎Readability counts link1 = "https://www.youtube.com/watch?v=kbxkq_w51PM" link2 = "https://youtu.be/KMBBjzp5hdc" print(link1[-11::]) print(link2[-11::])
26th Jul 2021, 1:28 PM
Lothar
Lothar - avatar
+ 1
import re text = input() p = r'(https://www\.youtube\.com/watch\?v\=)|(https://youtu\.be/)([\w]*)' m = re.match(p, text) if m: print(m.group(3)) Try with above code. Pattern 1 '(<1>)(<2>)|(<3>)(<4>)' Pattern 2 '(<1>)|(<2>)(<3)' Pattern 1 : matches with input (<1>)(<2>)(<4>) OR (<1>)(<3>)(<4>) AND Pattern 2 matches with input (<1>)(<3>) OR (<2>)(<3>) And output is available in (<3>) DHANANJAY PATEL
26th Jul 2021, 11:37 AM
DHANANJAY PATEL
DHANANJAY PATEL - avatar