Remove starting and ending forward slash

I have to get rid of the starting forward slash in a field value.
Field value is "/abc/par/xyz/"
I want this ti be muted as abc_par_xyz
I can replace '/' with '_' using gsub, but it gives me "abc_par_xyz"
How can I get rid of first and last '/'


Did you read what you posted? Your post says you want abc_par_xyz, but you get abc_par_xyz, which is the same thing. So it is unclear what you want. Perhaps you want to anchor you regexps in gsub?

mutate { gsub => [ "message", "^/", "", "message", "/$", "", "message", "/", "_" ] }

I don't know why prefix underscore not appearing in my post. When I edit, it shows, but when I save, it's not showing. However it gives me string whcih starts with underscore and ends with underscore, Which I don't want.
I want to get rid of starting and ending underscore character.

I hope you understand my problem.

Thanks a lot.
It worked.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.