Sign in to follow this  
Followers 0
DJKMan

How to extract YouTube links from random text.

3 posts in this topic

I know I need to use regular expression to do this. I'm not quite that good with regular expression yet.

I've read some articles and it appears no one has found an official solution for the dynamic youtube links.

Here's an example:

some text and then some text

Note: I grabbed these links from the example forums that have attempted to use regular expression to achieve this. I never really looked at the vids (it's not important).


My work in AutoIt (Not many yet):

Parse Large Text Files To 2D Array Quickly [With Chunk Size]

 

My artificial intelligence project coded entirely in AutoIt. Meet Alice Assistant: http://facebook.com/ProjectAliceAI

 

Share this post


Link to post
Share on other sites



DJKMAN,

This should work for you :mellow:

Dim $searchString = "some text http://www.youtube.com/watch?v=szygGmDsAl4&search_query=testing&search=Search and then some text" ; This could be a file

If FindYT($searchString) Then
    MsgBox(0, @ScriptName, "I found a YouTube link!")
Else
    MsgBox(0, @ScriptName, "No YouTube link :(")
EndIf

Func FindYT($ioString)
    Local $RegEx = "(http://www.youtube.com)?/(v/([-|~_0-9A-Za-z]+)|watch\?v\=([-|~_0-9A-Za-z&=]+)?.*?)"
    If StringRegExp($ioString, $RegEx) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc

James

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0