In my app I could have a URI like:
var hash = window.location.hash;
hash = hash.split(/cost.*&/);
No way. Oh, there is! Just wrap your regex in the capture group.
var s = '/items#rarity=rare,common,uncommon&cost=ascending&category=primary'; r = s.split(/(cost.*&)/); console.log(r); console.log(r); //there is the "thrown" part console.log(r);