Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!