Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

276
Vistas
How can i get the url from the string by using regular expression or any javascript method
    [
    "<iframe allowFullScreen frameborder=\"0\" height=\"564\" mozallowfullscreen src=\"https://player.vimeo.com/video/253266360\" webkitAllowFullScreen width=\"640\"></iframe>"
]

How can i get the below url from the above ptr string using reg exp: https://player.vimeo.com/video/253266360\ I am trying to split string but not able to get the url.

ptr.split(/(?=:)/)
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can extract a URL from a string using the following RegExp:

/(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))/

So to get the URL from that string:

const ptr = '<iframe allowFullScreen frameborder="0" height="564" mozallowfullscreen src="https://player.vimeo.com/video/253266360" webkitAllowFullScreen width="640"></iframe>'

const url = /(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))/.exec(ptr)[0];

When using RegExp.prototype.exec() you, the first element in the returned array is the full string that was matched, in this case https://player.vimeo.com/video/253266360. You can also remove the [0] from the end of the url expression to get the full returned array in case you need other information about the match.

See MDN Docs for more details on the RegExp.exec function.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Perhaps you can leverage the DOM API and do like;

var div = document.createElement("div"),
    src;

div.innerHTML = "<iframe allowFullScreen frameborder=\"0\" height=\"564\" mozallowfullscreen src=\"https://player.vimeo.com/video/253266360\" webkitAllowFullScreen width=\"640\"></iframe>";
src = div.firstChild.src;

console.log(src);

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda