Remove string where it is between special characters?

Hi,

Is there a way to find and remove a string where it is between special characters?
The special chars will always be ‘(’ and ‘)’.
I don’t really want to split the string as ‘(’ and ‘)’ can appear multiple times in a string and that could become quite complex. Can this be achieved through linq?

For example:

strTest: “this is a (test) string”

Should become: strTest: “this is a string”

The word ‘test’ is dynamic, only the ( ) remains constant.

Thank you

Replace through Regext.
[()]

system.text.RegularExpressions.Regex.Replace(inputString,“[(*)]”,“”)

1 Like

Hi,

how about the following expression?

System.Text.RegularExpressions.Regex.Replace(yourString,"\(.*?\)\s*","")

image

Regards,

1 Like

Excellent! Thanks very much for your quick & clear response.

@qwerty1 check now I updated my comment.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.