I am trying for a long time now to replace:
(a (b ((c) (d)) (e) :hello ((f (g) h)))))
by
(a (b ((c) (d)) (e)))
hello does not appear anywhere else in the string. If tried a lot of different stuff but thought it should work like this:
sed -i 's/\s:hello\s.*))//g'
However, it does not seem to match the first two parenthesis, i.e.
(a (b ((c) (d)) (e) :hello ((f (g) h ))))
but the last two
(a (b ((c) (d)) (e) :hello ((f (g) h)))))
and thus deletes everything after the :hello.
I also tried working with [^)]* but could only get it to take one parenthesis and not two and since there is a closing parenthesis after g it stopped there.