+ 3
YouTube Link Finder task
import re pattern = r"https://(www.)?[\w.]+/(watch\?v=)?([\w\d_]+)" url = input() match = re.match (pattern , url) if match: print (match.group(3)) My code isn't passing the fourth test case. What have I lost in my pattern?
13 ответов
+ 17
I might have taken a shortcut 😬
inp = input()
print(inp[-11:])
+ 7
Instead of this, I would suggest you try this idea. 
We know youtube video id is starting after the v= and we also know that length of the id is 11 characters. just find the v in the link and after the v= collect 11 characters which will be the id of the YouTube video.
+ 5
Thanks to YouTube video ID being 11 characters, my code was very simple, passed all the tests:
print(input()[-11:])
+ 1
This was my answer:
https://code.sololearn.com/cK8wjT3bSESH/?ref=app
It’s pretty straightforward.
+ 1
Easiest solution:
url = input()
if "=" in url:
    res = url.split("=")
else:
    res =url.split("/")   
     
print(res[-1])
+ 1
url = input()
if "watch" in url:
 print(url.replace("https://www.youtube.com/watch?v=" , ""))
else:
 print(url.replace("https://youtu.be/"  , ""))
0
Solution by Manohar (optimized)
import java.util.*;
class Manoher
{
    public static void main(String arg[])
    {
        Scanner sc=new Scanner(System.in);
        String accept=sc.nextLine(); //String accepted
        System.out.println(accept.substring(accept.length() -11));
    }
}
0
not optimized code
import java.util.*;
class YoutubeLinkFetcher
{
    public static void main(String arg[])
    {
        int no=0;
        String rev="";
        Scanner sc=new Scanner(System.in);
        String str=sc.nextLine();                // string accepted here
        
        for(int i=str.length();i>0;--i)  // 
         
        {
           
             rev= rev+(str.charAt(i-1)); // String has been reversed
                        
             no++;
             if(no==11)              
             {
                //System.out.println(rev);
                StringBuilder xx=new StringBuilder(rev);
                System.out.println(xx.reverse());
                
             }
            
        }
       
    }
}
0
import re 
pattern = r"https://(www.)?[\w.]+/(watch\?v=)?([\w\d_]+)" 
url = input() 
match = re.match (pattern , url) 
if match: 
 print (match.group(3))
 #print(match.group[-11:])
 #print(input()[-11:])
0
import re 
pattern = r"https://(www.)?[\w.]+/(watch\?v=)?([\w\d_]+)" 
url = input() 
match = re.match (pattern , url) 
if match: 
 print (match.group(3))
 #print(match.group[-11:])
 #print(input()[-11:])
- 1
This is my solutions 
url = str(input())
s = url.replace("/","").replace(":"," ").replace("="," ").replace("."," ")
ID = s.split()
if len(ID) >3:
  print(ID[4])
else:
  print(ID[2][2::])
- 2
file = open("/usercode/files/books.txt", "r")
#your code goes here
readfile=file.readlines()
for i in readfile:
    sv=i.split('\n')
    sv1= sv[0]
    sv2=sv[0][0]
    sv3=str(len(sv1))
    print(sv2+sv3)
file.close()
- 3
#The Simplest answer 😁
link =input('')
if '=' in link :
	lf1 = link.split('=')
	d = lf1[-1]
	print(d)
else:
    lf2= link.split('/')
    m = lf2[-1]
    print(m)














