I want to remove the content between 2 characters in a text with Visual C#.
Here is an example:
Given: Hi [everybody], I'm 22 years old, I'm a student [at a University of Technology] in Vietnam
Result: Hi, I'm 22 years old, I'm a student in Vietnam
I use this syntax
string input = "Hi [everybody], I'm 22 years old, I'm a student [at a University of Technology]";
string regex = "(\\[.*\\])";
string output = Regex.Replace(input, regex, "");
but the code is remove all between the first and the last square brackets, so this is the result:
Hi in Vietnam
How can I fix it ?