Referring to this How to convert part of a string that includes underscores to brackets in logstash with gsub
- what would be the reverse..
Input
Hello[1].Bye
Output
Hello_1_.Bye
CodePudding user response:
You could do that using mutate gsub ...
mutate { gsub => [ "someField", "[\[\]]", "_" ] }
The question is currently tagged as though it wants a solution using a ruby filter, but I cannot see any reason to do that.
CodePudding user response:
Input
a="Hello[1].Bye"
Code
p a.gsub(/([^\[]*)\[(.*)\]\.(.*)/,'\1_\2_.\3')
Output
"Hello_1_.Bye"