Solved

regex hrlp required for extracting ID from few video services

Posted on 2014-04-29
4
435 Views
Last Modified: 2014-05-20
Hi,

I am using couple of video services to diplay the videos to the users, now i have written some static code which will just fetch the id of the video url and play it in my video defined tag..

I am looking for regex for dailymotion, google video, livevideo, myspace, vimeo to extract the ID and give it to me, so i can use it

now there are few things, there is no one static url which can be used, it has different links to use the same id, so regex is becoming difficult to handle.

Like for vimeo i am using this code:

http://www.vimeo.com/moogaloop.swf?clip_id={Just need the ID to play it}
http://video.google.com.au/videoplay?docid=
http://livevideo.com/flvplayer/embed/
http://www.livevideo.com/flvplayer/embed/
http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=
http://www.dailymotion.com/swf/

Open in new window


the above is code which is i am using with the embed tag to play the videos.
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 29

Accepted Solution

by:
Pravin Asar earned 500 total points
ID: 40033587
<cfoutput>
    <cfset theUrl = "http://www.vimeo.com/moogaloop.swf?clip_id={Just need the ID to play it}" />
    <!--- Uses CF function --->
    <cfset theUrl = listRest(theUrl, "?")>
    <cfloop list="#theUrl#" index="URLPiece" delimiters="&">
        Key: #listFirst(urlPiece, "=")# Value: #listLast(urlPiece, "=")# <br />
    </cfloop>
</cfoutput>


You can do this in Javascript also.

Here is simple function and usage example in Javascript

<html>
      <script type="text/javascript">
      function getParameterByName(location,name) {
          name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
          var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location);
          return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
      }
      alert (getParameterByName("http://www.vimeo.com/moogaloop.swf?clip_id={Just need the ID to play it}","clip_id"));
      </script>
      
</html>
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 40033875
does that work for all or the specific ones
0
 
LVL 29

Expert Comment

by:Pravin Asar
ID: 40034410
Should work.

I noticed following url have no query parameters

http://livevideo.com/flvplayer/embed/
http://www.livevideo.com/flvplayer/embed/
http://www.dailymotion.com/swf/


So I do not know, how you will be able to get the video source file name
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 40040070
working on it
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question