这段代码移值到.NET中应该怎样改
另有一帖http://community.csdn.net/Expert/topic/4901/4901940.xml?temp=.4215509
一起结帖.    ''''正则式内容截取函数
    Function mymid(ByVal A_strString, ByVal A_strPattern, ByVal A_strBlip)
        Dim MM_objRegexp
        Dim MM_strExecute        MM_objRegexp = New regexp
        With MM_objRegexp
            .Pattern = A_strPattern
            .IgnoreCase = True
            .Global = False
            MM_strExecute = .Execute(A_strString)
            If MM_strExecute.count <> 0 Then
                mymid = .replace(MM_strExecute.item(0).value, A_strBlip)
            End If
        End With
        mymid = Trim(Replace(mymid, "        ", " "))
        MM_objRegexp = Nothing
    End Function

解决方案 »

  1.   

    Function mymid(ByVal A_strString, ByVal A_strPattern, ByVal A_strBlip)
            Dim MM_objRegexp as regexp
            Dim MM_strExecute        MM_objRegexp = New regexp
            With MM_objRegexp
                .Pattern = A_strPattern
                .IgnoreCase = True
                .Global = False
                MM_strExecute = .Execute(A_strString)
                If MM_strExecute.count <> 0 Then
                    mymid = .replace(MM_strExecute.item(0).value, A_strBlip)
                End If
            End With
            mymid = Trim(Replace(mymid, "        ", " "))
            MM_objRegexp = Nothing
        End Function
      

  2.   

    终于有人回了,谢谢楼上的!
    不过你的代码
    Dim MM_objRegexp as regexp 这里就出错提示"未定义类型"呀
      

  3.   

    是Regex 吧 查查MSDN里Regex类的用法,有C#或VB.NET语法的
      

  4.   

    我就是把
    MM_objRegexp = New regexp改成了
    MM_objRegexp = New regexp
    但这样改了之后,下面的
                .Pattern = A_strPattern
                .IgnoreCase = True
                .Global = False
    这几处代码又出错了,提示:
    Pattern是Protected,无法在此上下文中无法访问
    IgnoreCase不是System.Text.RegularExpressions.Regex中的成员
    Global不是System.Text.RegularExpressions.Regex中的成员