0
Who solved this problem? i think there is a problem with fourth test?
3 Respostas
+ 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.
+ 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::])
+ 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