Regular expression to match one of two video ID's in a Google Video URL
- by Baldur
I need to grab the video ID from a Google Video URL. There are two different types of URLs that I need to be able to match:
http://video.google.com/videoplay?docid=-3498228245415745977#
where I need to be able to match -3498228245415745977 (note the dash; -), and
video.google.com/videoplay?docid=-3498228245415745977#docid=2728972720932273543
where I need to match 2728972720932273543. Is there any good regular expression that can match this?
This is what I've got so far: @"docid=(-?\d{19}+)" since the video ID seems to be 19 characters except when it's prefixed with the dash.
I'm using C# (of which I have very little experience) if that changes anything.
P.s. I would also appreciate you review my regular expressions for YouTube (@"[\?&]v=([^&#])";), RedTube (@"/(\d{1,6})") and Vimeo (@"/(\d*)").
I do not expect users to enter the full URL and thus do not match the ^http://\\.?sitename+\\.\\w{2,3}.