Well, what I need to do is get a string via input, and "get" a certain value inside such a string. Below is an example to better illustrate the situation:
<iframe width="560" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?layer=c&panoid=goEpsYZX7pQAAAQIt-TW4A&ie=UTF8&source=embed&output=svembed&cbp=13%2C142.07416353827222%2C%2C0%2C-5.103108329005522"></iframe><div><small><ahref="https://www.google.com/maps/views/" style="color:#0000FF; text-align:left">Views</a>: <a href="https://www.google.com/maps/views/view/110823397966309387614/gphoto/5911594599652857186" style="color:#0000FF; text-align:left">Wien, Stephanplatz - at the Cathedral church Stephansdom.</a> de <a href="https://www.google.com/maps/views/profile/110823397966309387614" style="color:#0000FF; text-align:left">Bostjan Burger</a></small></div>
The purpose here is to retrieve the content within the src=
attribute. For this I wanted to use javascript, because I will use the onblur event so that when the user "pasts" the string I get the src=
and pass to a <iframe/>
display such content.
Starting from the premise that I could do this using a regular expression ".*src=\"(.+?)\".*", "$1"
using the replaceAll()
method of Java how could I do the same in javascript?
I did something, but without success:
document.getElementById("yt_input").onblur = function{
alert("Entrou no metodo...");
var input = document.getElementById("yt_input").value;
var expReg = ".*src=\"(.+?)\".*", "$1";
var resultado = expReg.exec(input);
alert("Valor do inputSplit:" + resultado[0]);
};
What would be the correct way to get this value in order to work on it later?