Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi i am using regex to grab link from a page and at the title and link to a datatable and then dispaly this in a datagridview this is all working great un till it gets to one point in my application

i need to get a link from inside this

HTML
<video autoplay="" class="vjs-tech" data-id="19240" data-number="1" data-season="1" data-setup="{}" data-show="sho1" data-title="show1" data-type="Video" id="my_video_html5_api" nativecontrolsfortouch="false" poster="thumb_MV5BMTI3ODc2ODc0M15BMl5BanBnXkFtZTYwMjgzNjc3.jpg" preload="metadata" src="webm" style="cursor: none;">
<source src="webm" type="video/webm">
<source src="mp4 video link i need to get" type="video/mp4">
</video>


now i tried to get this using regex with the following expreshion
HTML
<source src="()" type="()">

but it picks up nothing dose anyone have any ideas
Posted
Updated 1-Jun-14 14:47pm
v3
Comments
[no name] 1-Jun-14 18:07pm    
Did you read your question before you clicked the "Submit" button?
makemesecure 2-Jun-14 4:14am    
yes i did

i know how to use regex in fact it works great and collects all the other links and information i need from the page

the only problem is no matter what way i try it will not pic up the source mp4 video and link

i have a feeling its because this is an inner html eliment of the video tags
[no name] 2-Jun-14 7:11am    
I am not sure you did. If you had read it, you would have seen that your "regex" was blank. But after someone edited your question for you, at least something magically appeared.

1 solution

Learn Regex first. It's like eating with fork and knife: If you don't manage to handle them, you cut yourself. The same with any other "sharp" tool (like Regex, etc.).

For getting started quickly or for more elaborate tutorials, see:
- The 30 Minute Regex Tutorial[^]
- http://www.tutorialspoint.com/vb.net/vb.net_regular_expressions.htm[^]
- https://www.google.com/search?q=regex+tutorial+VB[^]

Is this quick enough for your "urgent" request? ;-)

Cheers
Andi

PS: "urgent" triggers a reflex with many people for just not answering at best, and down-voting the question so it gets deleted soon, at worst.
So, I "urge" you to strictly avoid "urgent" in any of the questions posted here.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 1-Jun-14 20:46pm    
Nice answer, a 5.
—SA
Andreas Gieriet 2-Jun-14 1:45am    
Thanks for your 5, Sergey!
Cheers
Andi
makemesecure 2-Jun-14 4:09am    
i know how to use regex in fact it works great and collects all the other links and information i need from the page

the only problem is no matter what way i try it will not pic up the source mp4 video and link

i have a feeling its because this is an inner html eliment of the video tags
Andreas Gieriet 2-Jun-14 6:03am    
If this is your RegEx, nothing will be matched:
source src="()" type="()"
That's why I suggest to learn first Regex.
Andi
PS: beside the regex issue: are you sure your HTML source viewer does not fool you by displaying the HTML sources in a "nicely" formatted form instead of the raw text? Open the HTML source in a plain text editor to make sure your HTML is as you expect. E.g. attributes may be in a different ordering, spaces may be different, new lines may be there too, etc.
makemesecure 2-Jun-14 15:50pm    
No that is not my regex this site seems to have removed the dot star and question mark from inside my brackets

<sourc src="(.*?)" type="(.*?)">

No I use a webclient to download the pages source code into a string and then use regex to find the matches inside that string

I can get normal herf links perfect file as well as the links text/title and I can get image URLs and I have it set to add the base URL to all broken links ass well as remove all javascript email and other nonsence stuff

The only problem is I can't get the video link it looks like this in the source code

Video id=1 title=video

Then it GOS to the inner HTML of the video element witch are source tags

Source type=webm SRC=linkhere
Source type=mp4 SRC=link here

Then it has the closing video tag

/video

This site didn't remove the HTML you may be able to see it properly I will try post a link to my code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900