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

188
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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