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

236
Vistas
how could set multi separator of "_.truncate" of Lodash?

how can I separate by "," or "-" or " " ?

    let _r = _.truncate('hi-diddly-ho there, neighborino', {
          'length': 16,
          'separator': /,- +/
        });
        console.log(_r);   //need output: hi
    
    let _r = _.truncate('hi!diddly ho there, neighborino', {
          'length': 16,
          'separator': /,- +/
        });
        console.log(_r);   //need output: hi!diddly
    
    let _r = _.truncate('hi!diddly!ho,there, neighborino', {
          'length': 16,
          'separator': /,- +/
        });
        console.log(_r);   //need output: hi!diddly!ho

if setting "/,- +/" is not working, what should I do?

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

0

Your regular expression is basically saying, "match ,- followed by at least one space".

Check it on Regex101

This would match ",- ", for example.

What you want is a character group of ,, - and space (note that you need to escape - there):

/[,\- ]/

Check it on Regex101

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