Regex for finding query param in url

Note To Self: a JavaScript function for getting a value of a specific query param of an URL.

function getQueryParam (qpn, url) {
    // qpn is short for queryParamName :)
    var paramRegEx = new RegExp(qpn+'=[^&]*'),
        testResult = paramRegEx.exec(url);

    // if there are many with same name, 
    // then we return the first
    if (testResult && testResult.length > 0) {
        return testResult[0].split('=')[1];
    }

    return null;
}

Here is an exmaple jsfiddle of how to use it.