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

273
Vistas
How to remove duplicate arithmetic operators using regex

this is my input string in react : 4-+3-4 I want to check onChange() function when a duplicate arithmetic entered, like this -+ replace last operator with first one, how can i detect that on change function? input should change on change to 4+3-4 I tried and tested but failed This is my regex for finding operators and last operator /[+*\/-]/g /[+*\/-]$/g

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You may try a regex replace approach:

var input = "4-+3-4";
var output = input.replace(/[*/+-]+([*/+-])/g, "$1");
console.log(output);

This approaches matches two or more successive arithmetic operators, capturing the final one. It then replaces with just this final operator.

about 4 years ago · Juan Pablo Isaza 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