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

85
Views
Regex with URLs as a string in switch-case statement

I have a switch statement which handles URLs. I'm looking to include "#xyz" at the end of the URLs without having to create new cases for each additional URL.

switch(window.location.href)
{
    case "mywebsite.com/blog":
    case "mywebsite.com/blog#intro":
    case "mywebsite.com/blog#sources":
    case "mywebsite.com/blog#contact":
        do something...
        break;
    case "mywebsite.com/home":
    case "mywebsite.com/blog#about":
    case "mywebsite.com/blog#email":
    case "mywebsite.com/blog#contact":
        do something...
        break;
}

Should ideally be:

switch(window.location.href)
{
    case "mywebsite.com/blog*":
        do something...
        break;
    case "mywebsite.com/home*":
        do something...
        break;
}
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!