Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Please how do i extract youtube video id from these links maybe using Regex

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please how do i extract youtube video id from these links maybe using Regex

    Last edited by sledjama; June 25th, 2011 at 10:08 AM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Please how do i extract youtube video id from these links maybe using Regex

    Or you could use indexOf() and substring()

  3. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please how do i extract youtube video id from these links maybe using Regex

    users will be supplying the youtube url, the video id will vary so i cant search for what i am actually looking for
    if i have it, why search i the first place.

    i copied this from someone's code (http://gdata-java-client.googlecode....iteClient.java)

    Pattern p = Pattern.compile("http.*\\?v=([a-zA-Z0-9_\\-]+)(?:&.)*");
    Matcher m = p.matcher(input);

    if (m.matches()) {
    input = m.group(1);
    }

    return input;
    something tells me i will be able to apply it but am not sure if it's right.

    Thanks Norm for your input

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Please how do i extract youtube video id from these links maybe using Regex

    Your posted example showed bounding []s that could be searched for.

    Or the leading v= and the ending &.


    See cross post at: http://www.java-forums.org/new-java/...ing-regex.html
    Last edited by Norm; June 25th, 2011 at 11:04 AM.

Similar Threads

  1. I want to extract minutes and seconds from duration
    By msa969 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 17th, 2011, 02:14 PM
  2. Replies: 2
    Last Post: March 16th, 2011, 06:32 AM
  3. How to extract text from web
    By HelloAll in forum Java Theory & Questions
    Replies: 4
    Last Post: January 10th, 2011, 05:50 AM
  4. How to extract a particular element details which has more references ???
    By j_kathiresan in forum Algorithms & Recursion
    Replies: 1
    Last Post: December 31st, 2009, 01:11 AM
  5. how to extract variables,keywords,operator...
    By Nanda in forum Java Theory & Questions
    Replies: 1
    Last Post: November 12th, 2009, 10:19 PM