var str = '<li><img src="http://placehold.it/80/35505?text=2" class="roulette-img" id="roulette-img190"></li>'; var result = /text=(\d{1,3})/.exec(str); if(result) { result = result[1]; alert(result); }