You could use a simple regular expression to match on employeeid
:
// Extract the employeeid with a RegEx
var employeeid = url.match(/;employeeid=(\d+)/, url)[1];
console.log(employeeid);
>>> 4
Or if you'd like this as a function so that any value can be selected you could use the following:
function getValue(url, name) {
var m = new RegExp(';' + name + '[=:](\\d+)', 'g').exec(url);
if (m) {
return m[1];
}
return '';
}
var age = getValue(
'/api/getValue;id=12345;age:25;employeeid=4?test=true&othervalues=test',
'age'
);
console.log(age);
>>> 25