[TxMt] Search and replace matching brackets?

Robin Houston robin.houston at gmail.com
Wed Aug 29 08:30:26 UTC 2007


On 29/08/2007, Nicholas Cole <nicholas.cole at gmail.com> wrote:
> But it would still be nice to search and replace matching things....

You can, using the recursion feature of Onigurama regular expressions.

For your footnote example, search for the following regular expression:

(?x:
	\\footnote\{
		(?<balanced>
			( [^{}] | \{\g<balanced>\} )*
		)
	\}
)

being careful *not* to put a newline after the final parenthesis, and
replace with

($1)

I've tested this, and it seems to work.

Robin



More information about the textmate mailing list