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