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

246
Vistas
How to convert part of a string that includes underscores to brackets in logstash with gsub

I want to convert, for e.g. Hello_1_.Bye to Hello[1].Bye Note that [1], i.e., within brackets contain only digits

I started with something like this that didn't work..

filter {
  mutate {
    gsub => ["String", "*_\D_.*", "*[\D].*"] //Note that String here could be Hello_1_.Bye, Hello_2_.Bye etc.
  }
 }

but getting this error

:exception=>#<RegexpError: target of repeat operator is not specified: /*_\D_*/>

Appreciate your help

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I suggest using this version:

filter {
  mutate {
    gsub => ["Hello_1_.Bye", "([^_]+)_(\d+)_(\.\w+)", "\1[\2]\3"]
  }
}

Here is a regex demo showing that the replacement is working.

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