简体   繁体   English

如何将包含括号的字符串的一部分转换为logstash中的下划线

[英]how to convert part of a string that includes brackets to underscores in logstash

Referring to this How to convert part of a string that includes underscores to brackets in logstash with gsub参考此如何使用 gsub 将包含下划线的字符串的一部分转换为logstash中的括号

  • what would be the reverse..反过来会怎样。。

Input输入

Hello[1].Bye

Output Output

Hello_1_.Bye

Input输入

a="Hello[1].Bye"

Code代码

p a.gsub(/([^\[]*)\[(.*)\]\.(.*)/,'\1_\2_.\3')

Output Output

"Hello_1_.Bye"

You could do that using mutate+gsub ...您可以使用mutate+gsub ...

mutate { gsub => [ "someField", "[\[\]]", "_" ] }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用gsub将包含下划线的部分字符串转换为logstash中的括号 - How to convert part of a string that includes underscores to brackets in logstash with gsub 如何使用logstash删除字段名称中的下划线? - How to remove underscores in field names with logstash? 如何通过RegEx或replaceAll删除包含特殊字符的部分字符串? - How to remove part of string that includes special characters by RegEx or replaceAll? regex 匹配括号内包含(或不包含)空格的字符串 - regex Match string inside brackets which includes (or not includes) spaces 如何使用正则表达式从Logstash的字段键中删除前缀下划线 - How to remove the prefix underscores from field keys in logstash using regex 如何使用正则表达式Java在方括号内用下划线替换破折号 - How to replace dashes with underscores within the square brackets using regex Java PHP,将带有方括号的字符串转换为数组 - PHP, Convert a string with brackets into an array 使用RegEx发出分割字符串,包括括号,分号和空格 - Issue splitting string with RegEx that includes brackets, semicolons and spaces 正则表达式包括字符串的一部分但不包括strig的另一部分 - Regex includes part of string but excludes another part of strig 如何在括号“)(”上拆分字符串? - How to split string on brackets “)(”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM