Ruby or groak for string menuplation

I have a two different type of string

example1_string = /a/b/c/./d/e ( if found . then I just want to remove only './' )
example2_sting = /a/b/c/../d/e ( if found .. anywhere in string then I want to just remove ' c/../' )

and if no . or no .. then leave it as is.

How do I achieve this?

and this string might be more or less in length, not exactly upto e.

Use mutate+gsub

 mutate { gsub => [ "message", "/\./", "/", "message", "/[^.]/\.\./", "/" ] }
1 Like

Thank you for fast reply Badger

. was removed. but .. didn't

here is example again
/a/b/change/../d/e -> /ab/d/e (this is result I am looking for)

If you need to match more than a single character then try

1 Like

@Badger you are star. done. working

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