Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using REGEXP activeX
Message
From
27/03/2017 18:16:55
 
 
To
27/03/2017 17:22:39
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Miscellaneous
Thread ID:
01649405
Message ID:
01649410
Views:
93
Likes (1)
>how can i extract the videoID of a youtube video player complet url by RegExp activeX ?
>
>local m.xpattern,m.url
>m.xpattern='/https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[?=&+%\w-]*/ig;'
>m.url="http://www.zyoutube.com/watch?v=GUEZCxBcM78&feature=pyv&feature=pyv&ad=10059374899&kw=%2Bwingsuit"
>*******************
>local regexObj
>regexObj = createobject('VBScript.RegExp')
>regexObj.Global = .t.
>regexObj.IgnoreCase = .f.
>regexObj.Pattern =m.xpattern	
>*............
>**************
>
>*result must be: GUEZCxBcM78
>
>note that urls can have many diffrent syntaxes but must be filtered by the xpattern..for ex:(i cutted the first part http://www. to avoid videos appear at bottom..as thumbs)
>
>.youtu.be/NLqAF9hrVbY
>.youtube.com/embed/NLqAF9hrVbY
>.youtube.com/embed/NLqAF9hrVbY
>.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US
>.youtube.com/watch?v=NLqAF9hrVbY
>.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo
>.youtube.com/ytscreeningroom?v=NRHVzbJVx8I
>.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/2/PPS-8DMrAn4
>.gdata.youtube.com/feeds/api/videos/NLqAF9hrVbY
>.youtube.com/watch?v=spDj54kf-vY&feature=g-vrec
>youtube.com/watch?v=GUEZCxBcM78&feature=pyv&feature=pyv&ad=10059374899&kw=%2Bwingsuit
>
I don't know if all I got all ids right (is PPS-8DMrAn4 an id?), but here it goes:
LOCAL RegEx AS VBScript.RegExp

m.RegEx = CREATEOBJECT("VBScript.RegExp")
m.RegEx.Ignorecase = .F.
m.RegEx.Multiline = .F.
m.RegEx.Global = .T.
m.RegEx.Pattern = "(\/watch\?v\=|\/\w+\?v=|\/|v=)([a-zA-Z0-9\-]+)($|\?|\&)"

LOCAL Source AS String
LOCAL ARRAY Samples[1]

CLEAR

TEXT TO m.Source NOSHOW
http://youtu.be/NLqAF9hrVbY
http://www.youtube.com/embed/NLqAF9hrVbY
https://www.youtube.com/embed/NLqAF9hrVbY
http://www.youtube.com/v/NLqAF9hrVbY?fs=1&hl=en_US
http://www.youtube.com/watch?v=NLqAF9hrVbY
http://www.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo
http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I
http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/2/PPS-8DMrAn4
http://gdata.youtube.com/feeds/api/videos/NLqAF9hrVbY
http://www.youtube.com/watch?v=spDj54kf-vY&feature=g-vrec
http://www.youtube.com/watch?v=GUEZCxBcM78&feature=pyv&feature=pyv&ad=10059374899&kw=%2Bwingsuit
ENDTEXT

LOCAL SampleIndex

FOR m.SampleIndex = 1 TO ALINES(m.Samples, m.Source)

	m.Matches = m.RegEx.Execute(m.Samples[m.SampleIndex])

	? m.Samples[m.SampleIndex]," id =", m.Matches.item(0).SubMatches(1)

ENDFOR

NLqAF9hrVbY
NLqAF9hrVbY
NLqAF9hrVbY
NLqAF9hrVbY
NRHVzbJVx8I
NRHVzbJVx8I
spDj54kf-vY
spDj54kf-vY
GUEZCxBcM78
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform