Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
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.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

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.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda