Searching RichTextBox and deleting all between

I'm having a little trouble trying to figure out how to search all the text in my RichTextBox and delete everything between the parentheses (including the parentheses). I have a lot of files with different comments wrote in the parentheses that may have different text in them.

Example : This is my text in the text box (AS YOU CAN SEE HERE). I am wanting to be able to read the entire text box (This would be another comment) and delete the out.

Result: This is my text in the text box. I am wanting to be able to read the entire text box and delete the out.

The rich text box are usually longer files than just a couple lines. Any help would be gratefully appreciated.


You can use a regular expression for this:

Regex r = new Regex("\(.+?\)");

If you are using a richtextbox or a textbox:

rtb.Text = r.Replace(rtb.Text,"");

You can do this without reading the file into the richttextbox:

string filetext = File.ReadAllText("file.txt");
filetext = r.Replace(filetext,"");

Or in one line:


You can loop all files in a directory:

foreach(string file in Directory.GetFiles(targetDirectory)

Need Your Help

Table layout only as wide as first image?

android xml android-layout

I'm building an Android app, and using a TableLayout ViewGroup to display my data.

expand and collapse row for ng-table not working

javascript html angularjs

I am trying to achieve an expand and collapse row for ng-table, basically what I want is if you click on row it expands with more detail.But currently all the rows get expanded on click. Does anyon...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.