Question: I used to embed YouTube video's via a link I have in a database. 

YouTube no longer allows me to embed in this fashion. Instead, I need to extract the video ID from the URL I have stored. 

Here is an example of the link: 

```
http://www.youtube.com/watch?v=72xSxQIRelc&amp;feature=youtube_gdata

```

The ID I need to extract is `72xSxQIRelc`. I know I could do something like: 

```
string vidID = 
    preURL.Substring(preURL.LastIndexOf("v=") + 2,
    preURL.Substring(preURL.LastIndexOf("v=") + 2).Length -
    preURL.Substring(preURL.LastIndexOf("&feature")).Length)

```

I've seen some Regex stuff on here that does this. I'm wondering if my way is horribly inefficient, comparatively. I'm also not a regex kung fu wizard, so I'm not sure if the solutions I'm seeing are scalable if YouTube changes the URL structure (in this case, it's hard coded to require v= as well as &feature).

My solution still seems pretty hackish to me. Is there a more efficient way of doing this?

---

**Added**

This app is wrapped in a **silverlight** solution, so I should mention that here. 

One posted solution was to use HttpUtility.ParseQueryString. That looked like it was the answer, up until I discovered that Silverlight's implementation of HttpUtility doesn't include the ParseQueryString method.

Answer: 
Why make it so complex?

Just use what already exists. Its a url. Its been here for 30 years try this

<http://www.stev.org/post/2011/06/27/C-HowTo-Parse-a-URL.aspx>
Try using String.split() method:

```
    String[] splitedUrl=preURL.split("v=",StringSplitOptions.None);
    String[] splitedUrl2=splitedUrl[1].split('&');
    String vidID=splitedUrl2[0];

```

Then you'll have that vidID.