FireFox Posted May 5, 2011 Share Posted May 5, 2011 (edited) Hi,Everything is in the title, here is the different youtube urls i know, If you've got more then tell me http://www.you tube.com/watch?v=videoid << remove the space http://www.youtube.com/embed/videoid http://youtu.be/videoidIf you can not make one regexp because the short youtube url is verry different from the others, you can make two regexps.Br, FireFox. Edited May 6, 2011 by FireFox Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 5, 2011 Share Posted May 5, 2011 No, everything is not in the title. Actually, very little is in the title (or body) of the OP. What does "Check" mean? Check for what? What have you tried? Post a short symptom reproducer script. Given your example input URLs, what were you looking for from each by way of a RegExp? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GEOSoft Posted May 5, 2011 Share Posted May 5, 2011 In order to get any decent help with RegExps you need to show us the possible input values and the output that you expect from each one. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
FireFox Posted May 5, 2011 Author Share Posted May 5, 2011 (edited) In order to get any decent help with RegExps you need to show us the possible input values and the output that you expect from each one. I though I had enough explained, anyway. I'm crap with regexp so I havn't got it working at all. I want to know if the string is a valid youtube video url, and I think the most efficient way is to do it with regexp. Here is the possibilities : (remove the spaces) http://www. youtube.com/watch?v=wagn8Wrmzuc http://www. youtube.com/watch?v=wagn8Wrmzuc&feature=player_embedded http://youtu.be/wagn8Wrmzuc http://www.youtube.com/embed/wagn8Wrmzuc FireFox. Edited May 5, 2011 by FireFox Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 5, 2011 Share Posted May 5, 2011 So, list your rules for YouTube validity. Once you do that clearly, implementing the rules in code is the easy part. If the rules are vague (or non-existent as we have here), then no amount of code can help you. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GEOSoft Posted May 5, 2011 Share Posted May 5, 2011 (edited) If StringRegExp($sStr, "(?m:^)(http://[w.]*youtu\.?be[.com]*/.+)(?:\v|$)+") Then $sValid = " valid" Else $sValid = " not valid" EndIf MsgBox(0, "Result", $sStr & @CRLF & "is " & $sValid) Edited May 5, 2011 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted May 5, 2011 Share Posted May 5, 2011 Glad it worked and infact there was no real reason why it should based on the information you gave us. Don't blame anyone if it fails at some point. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
FireFox Posted May 5, 2011 Author Share Posted May 5, 2011 (edited) Glad it worked and infact there was no real reason why it should based on the information you gave us. Don't blame anyone if it fails at some point. yep, it doesn't work in some cases, I will try to explain exactly what I want : The only thing which can change in the url is the video ID, for example in your example if I remove the dot before "com" it will say that the link is valid but it's not the case. Between [ ], the string must be the same or the url will be invalid : [http://www.youtube.com/watch?v=]wagn8Wrmzuc [http://www.youtube.com/watch?v=]wagn8Wrmzuc&feature=player_embedded [http://youtu.be/]wagn8Wrmzuc [http://www.youtube.com/embed/]wagn8Wrmzuc FireFox. Edited May 5, 2011 by FireFox Link to comment Share on other sites More sharing options...
bwochinski Posted May 6, 2011 Share Posted May 6, 2011 Am a bit rusty on some Regex, but throwing in an attempt... Global $aURLs[5] = ["http://www.youtube.com/watch?v=wagn8Wrmzuc", _ "http://www.youtube.com/watch?v=wagn8Wrmzuc&feature=player_embedded", _ "http://www.youtubecom/watch?v=wagn8Wrmzuc", _ "http://youtu.be/wagn8Wrmzuc", _ "http://youtube.com/embed/wagn8Wrmzuc"] For $sStr In $aURLs If StringRegExp($sStr, "http://(?:www\.)?youtu(?:\.be/|be\.com/(?:embed/|watch\?v=))[^&%\v+?].*") Then ConsoleWrite("VALID! - " & $sStr & @CRLF) Else ConsoleWrite("NOT VALID! - " & $sStr & @CRLF) EndIf Next Link to comment Share on other sites More sharing options...
smartee Posted May 6, 2011 Share Posted May 6, 2011 yep, it doesn't work in some cases, I will try to explain exactly what I want : The only thing which can change in the url is the video ID, for example in your example if I remove the dot before "com" it will say that the link is valid but it's not the case. Between [ ], the string must be the same or the url will be invalid : [http://www.youtube.com/watch?v=]wagn8Wrmzuc [http://www.youtube.com/watch?v=]wagn8Wrmzuc&feature=player_embedded [http://youtu.be/]wagn8Wrmzuc [http://www.youtube.com/embed/]wagn8Wrmzuc FireFox. hi FireFox, here's my shot at it,#include <Array.au3> $matchArr = StringSplit("Invalid,Valid", ",", 2) $RegExp="(?i)^http://((www\.)?youtube\.com/(watch\?v=|embed/)|youtu\.be/)[a-z0-9_]{11}($|&[a-z0-9_=&]*)" Dim $testArray[10][2] $testArray[0][0] = "http://www.youtube.com/watch?v=wagn8Wrmzuc" $testArray[1][0] = "http://www.youtu.be/wagn8Wrmzuc" $testArray[2][0] = "http://youtube.com/watch?v=wagn8Wrmzuc" $testArray[3][0] = "http://youtu.be/wagn8Wrmzuc" $testArray[4][0] = "http://www.youtube.com/watch?v=wagn8WrmzucR" $testArray[5][0] = "http://.youtube.com/watch?v=wagn8Wrmzuc" $testArray[6][0] = "http://www.youtube.com/watch?v=wagn8Wrmzuc&feature=player_embedded" $testArray[7][0] = "http://www.youtue.com/watch?v=wagn8Wrmzuc" $testArray[8][0] = "http://youtube.com/embed/wagn8Wrmzuc" $testArray[9][0] = "shttp://www.youtube.com.watch?v=wagn8Wrmzuc" For $i = 0 To 9 $testArray[$i][1] = $matchArr[StringRegExp($testArray[$i][0],$RegExp)] Next _ArrayDisplay($testArray) Hope this helps -smartee Am a bit rusty on some Regex, but throwing in an attempt... Global $aURLs[5] = ["http://www.youtube.com/watch?v=wagn8Wrmzuc", _ "http://www.youtube.com/watch?v=wagn8Wrmzuc&feature=player_embedded", _ "http://www.youtubecom/watch?v=wagn8Wrmzuc", _ "http://youtu.be/wagn8Wrmzuc", _ "http://youtube.com/embed/wagn8Wrmzuc"] For $sStr In $aURLs If StringRegExp($sStr, "http://(?:www\.)?youtu(?:\.be/|be\.com/(?:embed/|watch\?v=))[^&%\v+?].*") Then ConsoleWrite("VALID! - " & $sStr & @CRLF) Else ConsoleWrite("NOT VALID! - " & $sStr & @CRLF) EndIf Next Your code mistakes some of my invalid urls to be valid, you should indicate the expressions' start and end, and www.youtu.be/... shouldn't be valid Hope this helps Link to comment Share on other sites More sharing options...
bwochinski Posted May 6, 2011 Share Posted May 6, 2011 Your code mistakes some of my invalid urls to be valid, you should indicate the expressions' start and end, and www.youtu.be/... shouldn't be valid Hope this helps Good catch, thanks. I did forget to specify start and end and I didn't realize that youtu.be didn't work with the www, never thought to check.Think your expression covers it all though. Link to comment Share on other sites More sharing options...
FireFox Posted May 6, 2011 Author Share Posted May 6, 2011 Your code mistakes some of my invalid urls to be valid, you should indicate the expressions' start and end, and www.youtu.be/... shouldn't be valid I didn't know that, you made a very good work ! @smartee, @bwochinskiThanks both for your help Br, FireFox. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now