Alex Rivera | Logout

Find string between two strings in Javascript or jQuery

Asked 2011-05-03T19:34:59.873
11

I have been trying to get a string between two strings in a line. I found a lots of tutorials using regex but as i am not that good at regex, i am not being able to figure out how to do it. Any help will be appreciated.

var fullUrl = "http://something.com/File/?URL=http://www.wireshock.com/&IP=0.0.0.0&CAT=BLOG&USER=MAND\\DEFAULT\\market4080";

i need to figure out a way to get the string between http://something.com/File/?URL= and &IP= and just return http://www.wireshock.com. I dont want to split the strings from "&" and get the middle string as it corrupts some urls with the & character in it. Any help would be appreciated. Thanks :)

Edit
Report

1 Answer

1

This code will give you the exact result as you want:

var url = fullUrl.split('?URL=')[1].split('/&IP=')[0];
answered 2013-01-29T12:36:27.317

Your Answer