var str = "<iframe width='420' height='315' src='http://www.youtube.com/embed/vILJLHn2v-Y?rel=0' frameborder='0' allowfullscreen></iframe>"; alert(str.split("/")[str.split("/").length-2].split("?")[0]);