Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

43
Vistas
regex issue in Safari

I need to split a string that looks like "12+3-4=" into an array that looks like ["12", "+", "3", "-", "4", "="]

The regex I used works in Chrome, but not in Safari and after doing google search I realized that Safari doesn't yet support lookbehinds. Is there another way to write the following regex so that it does the above, but works in Safari too?

const arr = displayValue.split(/(?=[\-\+\/\*\=])|(?<=[\-\+\/\*\=])/)

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try using match with an alternation:

var input = "12+3-4=";
var parts = input.match(/\d+|[*/=+-]/g);
console.log(parts);

7 months 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 empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.