Regex ignore URL already in HTML tags

Try this (?<!href=”)(\b[\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/]) See it here on Regexr To make it more general you can simplify your lookbehind to check only for “=”” (?<!=”)(\b[\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/]) See it on Regexr (?<!href=”https://stackoverflow.com/questions/9567836/) is a negative lookbehind assertion, it ensures that there is no”href=”” before your pattern. \b is a word boundary that anchors the start of your link … Read more

Creating a new Location object in javascript

Well, you could use an anchor element to extract the url parts, for example: var url = document.createElement(‘a’); url.href = “http://www.example.com/some/path?name=value#anchor”; var protocol = url.protocol; var hash = url.hash; alert(‘protocol: ‘ + protocol); alert(‘hash: ‘ + hash); ​ It works on all modern browsers and even on IE 5.5+. Check an example here.

How to convert URL parameters to a JavaScript object? [duplicate]

In the year 2021… Please consider this obsolete. Edit This edit improves and explains the answer based on the comments. var search = location.search.substring(1); JSON.parse(‘{“‘ + decodeURI(search).replace(/”/g, ‘\\”‘).replace(/&/g, ‘”,”‘).replace(/=/g,'”:”‘) + ‘”}’) Example Parse abc=foo&def=%5Basf%5D&xyz=5 in five steps: decodeURI: abc=foo&def=[asf]&xyz=5 Escape quotes: same, as there are no quotes Replace &: abc=foo”,”def=[asf]”,”xyz=5 Replace =: abc”:”foo”,”def”:”[asf]”,”xyz”:”5 Suround with … Read more

Change URL parameters and specify defaults using JavaScript

I’ve extended Sujoy’s code to make up a function. /** * http://stackoverflow.com/a/10997390/11236 */ function updateURLParameter(url, param, paramVal){ var newAdditionalURL = “”; var tempArray = url.split(“?”); var baseURL = tempArray[0]; var additionalURL = tempArray[1]; var temp = “”; if (additionalURL) { tempArray = additionalURL.split(“&”); for (var i=0; i<tempArray.length; i++){ if(tempArray[i].split(‘=’)[0] != param){ newAdditionalURL += temp + … Read more