Remove text between brackets in string

I’m trying to remove text in a string between brackets. I’m using .Replace(“(\w+)”,“”) but does not seem to be working.

If i have text e.g. Text1 (Text2) Text3 i wanted to remove (Text2) so i am left with e.g. Text 1 Text 3

Buddy @jon1302

If stored as in_text = Text1 (Text2) Text3

in_text = split(in_text," “)(0)+” “+split(in_text,” ")(2)


1 Like

You can use regex to replace text. See a sample pattern below.


Dim pattern As String = "\(.*\)"
Dim input As String = "Text1 (Text2) Text3"
Dim regex = New Regex(pattern)
Dim output = regex.Replace(input, "")
1 Like

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