Hi Everyone

I need some help. I would like to remove characters from a string that are contained in brackets. For example string (Hello)World, I want to remove the (Hello) part. Is there a way. I can't solve it with the replace or remove methods. I am new to C# and some help would be great.

Thank you

Johan

I did something like this to solve my problem. Maybe it helps someone else.

private void btnRemove_Click(object sender, EventArgs e)
        {
            String strTest = "(Test)Word";

            int iS = strTest.IndexOf('(');

            int jS = strTest.LastIndexOf(')');

            String newOne = strTest.Remove(iS, jS + 1);

            MessageBox.Show(newOne);
}

The output is Word.

Thanks to everyone for helping me out.

Johan

Hello

Didn't think about it. In my case there's only one bracketed word so that will do just fine :)

Johan

This question has already been answered. Start a new discussion instead.