Answers for "get string from url"

7

js get query param

const queryString = window.location.search;
const parameters = new URLSearchParams(queryString);
const value = parameters.get('key');
Posted by: Guest on June-25-2020
3

get url from string javascript

function Purify(text) {
    var urlRegex = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
    return text.replace(urlRegex, function (url) {
        return '<a class="text-blurple" target="_blank" href="' + url + '">' + url + '</a>';
    })
}
Posted by: Guest on October-03-2021
4

javascript get query parameter

function getUrlParameter(name) {
    name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
    var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
    var results = regex.exec(location.search);
    return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
Posted by: Guest on June-27-2019
0

get url from string javascript

var testUrl = variable.match(/'(http:[^\s]+)'/)
Posted by: Guest on August-08-2021

Code answers related to "get string from url"

Code answers related to "Javascript"

Browse Popular Code Answers by Language