Extracting a certain section from text

Hi,

I have the following code and I want to extract the URL from it.

<iframe width="560" height="315" src="http://www.youtube.com/embed/-cZ4mdrlWYM" frameborder="0" allowfullscreen></iframe>

I checked some jquery regular expression examples but couldn’t connect the dots. Do you have any ideas on how to do that?

Thanks.

What about:

var src = document.getElementsByTagName('iframe')[0].src;
console.log(src);

Actually, it is not an element. That code will be pasted into a textarea and I want to filter it and display only the URL as the user pastes it.

Oh sorry.

Try this:

var str = '<iframe width="560" height="315" src="http://www.youtube.com/embed/-cZ4mdrlWYM" frameborder="0" allowfullscreen></iframe>';
var src = str.match(/src="(.*?)"/);
console.log(src[1]);

It worked nice! Thank you very much Pullo.