var str = 'http://www.youtube.com/watch?feature=df3232&v=H9H0ocq1wLs&olo=11', str2 = 'http://www.youtube.com/watch?v=H9H0ocq1wLs'; alert( [str.split( /[\S\s]*v=|&/)[1],str2.split( /[\S\s]*v=|&/)[1]] )