I can't seem to find the correct JavaScript regular expression syntax to take a url string, get characters between other specified characters to encode, then insert back. My example may be easier to explain:
Example:
var url = 'http://www.myurl.com?t=23&dbUrl=http://www.encodeurl.com?t=23&otherUrl=http://www.anotherurl.com'
I need to grab the value between '&dbUrl=' and the next instance of 'http'. Take that value, 'encodeURIComponent' it, then insert it back into the var url to get:
I tried splitting it at any instances of http and just encoding the [1]index of it but I don't always know when in the string '&dbUrl' will exist. I am not looking to break every query parameter but only alter the url between one query parameter and any instance of the next instance of 'http'. Only because the other query param, example used: '&otherUrl=' I wont know the exact query param so I wouldn't know when it stopped unless looking for the http. I will only know the query param of '&dbUrl='. Any ideas?