abc="张小姐(敦美美)敦小姐(敦美美)(兽兽)"
去掉()和里面的内容如何得到张小姐敦小姐

解决方案 »

  1.   

    '此代码由“正则测试工具  v1.1.35”自动生成,请直接调用TestReg过程
    Private Sub TestReg()
        Dim strData As String
        Dim reg As Object    strData = "张小姐(敦美美)敦小姐(敦美美)(兽兽)"    Set reg = CreateObject("vbscript.regExp")
        reg.Global = True
        reg.IgnoreCase = True
        reg.MultiLine = True
        reg.Pattern = "\(.*?\)"
        Debug.Print reg.Replace(strData, "")
    End Sub
      

  2.   


    Option ExplicitPrivate Sub Command1_Click()
        Dim abc As String
        abc = "张小姐(郭美美)郭小姐(郭美美)(兽兽)"
        abc = Replace(abc, "(郭美美)", "")
        abc = Replace(abc, "(兽兽)", "")
        Debug.Print abc
    End Sub
      

  3.   

    发现楼主将2楼的给忽略了,估计是看不懂了修改下吧Option ExplicitPrivate Sub Command1_Click()
        Dim abc As String
        Dim reg As Object
        abc = "张小姐(郭美美)郭小姐(郭美美)(兽兽)"    Set reg = CreateObject("vbscript.regExp")
        reg.Global = True
        reg.IgnoreCase = True
        reg.MultiLine = True
        reg.Pattern = "\(.*?\)"
        abc = reg.Replace(abc , "")
        Debug.Print abc
    End Sub