# How to selectively delete a function together with its matching sets of brackets?

For example, suppose I want to retain only the content inside the argument of Distribute

Distribute[...Lengthly list of expressions ...]
+ Distribute[...Lengthly list of expressions ...] + ..
(hundreds of such terms)


I could do a full document delete of the search item Distribute[ but would not be able to do the same for ] since the closing bracket may appear in other places where I want it to remain.

• Quick and dirty fix: Find and replace Distribute with Identity. But I'm sure you're looking for something more elegant. – jjc385 May 1 '18 at 16:15
• If your want to actually edit the code, then I don't think it's related to Mathematica. I'd try with Vim, emacs or perl, etc. – anderstood May 1 '18 at 16:24
• ctrl+F and this. – AccidentalFourierTransform May 1 '18 at 16:25
• Ok. Identity it is... – Quasar Supernova May 1 '18 at 16:28