Search code examples
javascriptjqueryquery-stringexpression

remove url parameters with javascript or jquery


I am trying to use the youtube data api to generate a video playlist.

However, the video urls require a format of:

youtube.com/watch?v=3sZOD3xKL0Y

but what the api generates is:

youtube.com/watch?v=3sZOD3xKL0Y&feature=youtube_gdata

So what I need to do is be able to select everything after and including the ampersand(&) and remove it from the url.

Any way to do this with javascript and some sort of regular expression?


Solution

  • What am I missing?

    Why not:

    url.split('?')[0]