Por favor, resuelva mi problema. Tengo un área de texto. En esta área de texto, ingreso varias URL de videos de YouTube (línea por línea). Mi pregunta es cómo almacenar cada url como matriz usando javascript. Gracias por adelantado.
Este código debería funcionar, textarea el valor del área de texto según el salto de línea como mencionaste (línea por línea).
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>La forma más sencilla sería usar expresiones regulares como esta ( textareaValue contiene el valor de textarea):
const matches = textareaValue.match(/\bhttp(s)?:\/\/(www.)?youtu(be|.be).*\b/gm); Las matches serán una matriz de direcciones URL que comienzan con http(s)://(www.)youtube