var str = '#anotherdata=value#iamlookingforthis=226885#id=101&start=1'; var value = str.match(/#iamlookingforthis=(d+)/i)[1]; alert(value); // 226885