JSFiddle - React, Tailwind, and code Playground

by joycse06

JavaScript

function getParameterByName(name,url) {

    var match = RegExp('[?&]' + name + '=([^&]*)')
                    .exec(url);

    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));

}
alert(getParameterByName('q','www.test.com?q=1'))