Sublime Forum

How to delete text and brackets between two brackets

#1

Hi !

How can I in find and replace delete texts and brackets between two brackets ?

I am on a mac and have an TextEdit file to modify.

I can noit find the right script …

Thanks for your help!

0 Likes

#2

You can do this with regular expressions (regex). They can be confusing when you first learn them, but very powerful.

Imagine you have this string:

This is a string (that includes brackets).   
Lets delete the brackets and whatever is inside them.

Using Find and replace:

Find: \(.*?\)
Replace:

Result:

This is a string .   
Lets delete the brackets and whatever is inside them.

Note, you might also want to account for whitespace before and/or after the brackets:

Find: _?(.*?)_? (where _ is a whitespace)
Replace:

Result:

This is a string.   
Lets delete the brackets and whatever is inside them.
0 Likes