JSFiddle - React, Tailwind, and code Playground

by tjdragon

HTML

<span id="test">Click me</span>

JavaScript

$(function(){
    $("#test").click(function(){
    alert(getParameterByName('user',four));
          });
});
var one = '/news/local/edit?user=marcus&owner=ffff';
var two = '/news/other/edit?user=josh&owner=ddd';
var three = '/news/local/edit?user=john';
var four = '/news/local/test/marcus/edit?owner=aaaa&user=ady';

function getParameterByName(name, path) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(path);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}