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

206
Vistas
This Reguler Expression not working within JS Function . Does anyone know the reason?

I made regex and I applied it within this function. I tested on regex engine and its working fine but I don't know why it does not within this JS Function

function validURL(str) {
  var pattern = new RegExp(
'^((https?)://)(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z]'+
'[A-Za-z0-9\-]*[A-Za-z0-9])(:[0-9]*)?'+
'(?:\/[\+~%\/\.\w\-]*)?\??(?:[\-\+=&;%@\/%\.\w]*)#?'+
'([\-\+=&;%@\/%\.\w]*)$',"i"  );
  var isValid = pattern.test(str);
  return isValid;
}

Input: https://www.xml.com/pub/a/2003/09/17/stax.html#id=_abc

Output Result: it gives me syntax errors. Can anyone advise me with a reason?

Thanks in advance

Best regards

about 4 years ago · Juan Pablo Isaza
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