![]() |
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. |
You're regex seem ok, but I don't understand "to work with /v/videoid"
|
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)) { |
all this (http:\/\/)?(www\.)?(youtube\.com)?(\/)?(watch\?)?(v=)? is useless, because you've made it optional using the "?"
|
do you need all those parts or only the video id?
|
/http:\/\/?(www\.)youtube\.com\/(watch\?v=)|(\/v\/)?([a-zA-Z0-9]{11})/
can clean it up a lot if you want |
the servers are humming
|
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&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&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object> |
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