How to remove all characters between two brackets?

来源:互联网 发布:java 特种兵 pdf 编辑:程序博客网 时间:2024/05/11 06:04
How to remove all characters  between two brackets?
 
Such as "12345 (rtetnj) dsfd (fddsgd) dsf "----> "12345  dsfd  dsf "
 
Use regexp syntaxes ,it's too simple .
 
Function StringWithoutBrackets(ByVal s As String) As String
With CreateObject("VBSCRIPT.REGEXP")
    .Global = True
    .Pattern = "[(][^)]*[)]"
    StringWithoutBrackets = .Replace(s, "")
End With
End Function
 

Sub test()
MsgBox StringWithoutBrackets("12345 (rtetnj) dsfd (fddsgd) dsf ")
End Sub