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

187
Vistas
How to get each youtube url from textarea in JavaScript?

Please solve my problem. I have a textarea. In this textarea i enter multiple youtube video url(line by line). My question is how to store each url as array using javascript. Thanks in advance.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

This code should works, I split the textarea value based on line break as you mentioned (line by line).

 let textarea = document.querySelector('textarea')
    let arr = []
    function check(){
      arr = textarea.value.split('\n')
      console.log(arr)
    }
<textarea>https://www.youtube.com/watch?v=EqboAI-Vk-U&t=22s
https://www.youtube.com/channel/UCK8sQmJBp8GCxrOtXWBpyEA</textarea>
 <button onclick = 'check()'>Check</button>

about 4 years ago · Juan Pablo Isaza Denunciar

0

The simplest way would be to use regex like this (textareaValue contains the value of textarea):

const matches = textareaValue.match(/\bhttp(s)?:\/\/(www.)?youtu(be|.be).*\b/gm);

The matches will be an array of the urls that start with http(s)://(www.)youtube

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