Skip to content

Instantly share code, notes, and snippets.

View nilsorathiya's full-sized avatar

Narendra Sorathiya nilsorathiya

View GitHub Profile
@nilsorathiya
nilsorathiya / YouTubeHelper.java
Last active October 19, 2018 15:52 — forked from jvanderwee/YouTubeHelper.java
Extract video id from YouTube url in java
import com.google.inject.Singleton;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Singleton
public class YouTubeHelper {
final String youTubeUrlRegEx = "^(https?)?(://)?(www.)?(m.)?((youtube.com)|(youtu.be))/";
final String[] videoIdRegex = { "\\?vi?=([^&]*)","watch\\?.*v=([^&]*)", "(?:embed|vi?)/([^/?]*)", "^([A-Za-z0-9\\-_]*)"};