我想轉換,例如 Hello_1_.Bye 到 Hello[1].Bye 注意[1],即括號內只包含數字
我開始用這樣的東西不起作用..
filter {
mutate {
gsub => ["String", "*_\D_.*", "*[\D].*"] //Note that String here could be Hello_1_.Bye, Hello_2_.Bye etc.
}
}
但收到此錯誤
:exception=>#<RegexpError: target of repeat operator is not specified: /*_\D_*/>
感謝你的幫助
uj5u.com熱心網友回復:
我建議使用這個版本:
filter {
mutate {
gsub => ["Hello_1_.Bye", "([^_] )_(\d )_(\.\w )", "\1[\2]\3"]
}
}
這是一個正則運算式演示,顯示替換作業正常。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/389768.html
