- 1
Can anyone help me in java coad coach
import java.util.regex.Pattern; import java.util.regex.Matcher; import java.util.*; public class Joke { public static String extractYTId(String ytUrl) { String vId = null; Pattern pattern = Pattern.compile( "^https?://.*(?:youtu.be/|v/|u/\\w/|embed/|watch?v=)([^#&?]*).*
quot;, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(ytUrl); if (matcher.matches()){ vId = matcher.group(1); } return vId; } } public static void main(String[] args) { Scanner scan = new Scanner(System.in); Joke obj = new Joke; obj.extractYTId(scan); }3 ответов
+ 10
It'd be easier for people to help you if your attempt was linked via a code-playground URL.
+ 3
I don't really know a lot of Java. I'm sure someone will get around to look at it.
+ 2
Hello Pratik Shinde
Your method is in same class like main method and it is static. So you don't need an instance of Joker.
And the method returns a String:
String link = extractYTId(scan);
Now you can print this String to see if it works.