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

187
Views
how to match and replace multiple route parameter using angular replace function

I'm trying to replace multiple parameter using angular replace function but the problem that the function detected the first parameter.

eg: I have this route admin/management/{type}/card/{id}, the route.replace function result admin/management/waiting/%7Bid%7D it work fine with the first parameter.

/**
 * @param route 
 * @param obj 
 * @returns 
 */
  getFormattedRouter(route: String, obj: any) {
    console.log(route);//admin/management/{type}/card/{id}
    return route.replace(/{([a-zA-Z_]+?)}/, function (match, capture) {
      console.log(match);//{type}
      console.log(capture);//waiting
      //detected the first one then stops
      return obj[capture];
      //admin/management/waiting/%7Bid%7D
    });
  }

how can I detect all the parameters in a route.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your regexp does not seem to be capturing all the matches, you can try this instead /({\w*})/g. Note also the g at the end that indicates the fact that you want to find all the matches, not stop after the first one. Check this link for more info.

over 4 years ago · Santiago Trujillo Report
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!