GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   regex help (https://gfy.com/showthread.php?t=1003651)

fris 12-28-2010 07:31 AM

regex help
 
trying to get this youtube regex to work with /v/videoid as well as regular youtube links.

(http:\/\/)?(www\.)?(youtube\.com)?(\/)?(watch\?)?(v=)?([a-zA-Z0-9]{11})

here is the current regex suggested by borked.

iwiiiiiiiiii 12-28-2010 07:40 AM

You're regex seem ok, but I don't understand "to work with /v/videoid"

Kiopa_Matt 12-28-2010 07:45 AM

I don't understand what you're trying to do. Just get the video ID? Assuming it's PHP:

Code:

if (preg_match("/\?([\w\d]+)/", $url, $match)) {
    $video_id = $match[1];
} else { echo "No Video ID"; }

You don't need that combumbulated mess of a regex.

margarita 12-28-2010 07:48 AM

all this (http:\/\/)?(www\.)?(youtube\.com)?(\/)?(watch\?)?(v=)? is useless, because you've made it optional using the "?"

u-Bob 12-28-2010 07:51 AM

do you need all those parts or only the video id?

u-Bob 12-28-2010 07:56 AM

/http:\/\/?(www\.)youtube\.com\/(watch\?v=)|(\/v\/)?([a-zA-Z0-9]{11})/

can clean it up a lot if you want

2012 12-28-2010 08:05 AM

the servers are humming

fris 12-28-2010 08:58 AM

im trying to get the video id from these types

https://youtube.com/v/dgCrY8Mezd4

https://youtube.com/watch?v=dgCrY8Mezd4

https://youtube.com/watch?v=dgCrY...ure=grec_index

also

embed codes

Code:

<object width="640" height="385"><param name="movie" value="https://youtube.com/v/xVvRfMZ-3s4?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://youtube.com/v/xVvRfMZ-3s4?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>

iwiiiiiiiiii 12-28-2010 10:02 AM

What u-bob gave you should work.


All times are GMT -7. The time now is 12:43 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123