在网上找到这段用正则式截取内容的函数,请问怎么移值到.NET中来, MM_objRegexp = New regexp 这一句总是出错.    ''''正则式内容截取函数
    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.   

    首先添加using System.Text.RegularExpressions;
    該出錯語句改為:
    System.Text.RegularExpressions.Regex reg = new Regex(A_strPattern);
      

  2.   

    应该是VB.NET吧,用imports System.Text.RegularExpressions
    出错语句改为dim MM_objRegexp = New regexp
      

  3.   

    照楼上老兄的说的改成这样了:
        Function mymid(ByVal A_strString, ByVal A_strPattern, ByVal A_strBlip)
            Dim MM_strExecute
            Dim MM_objRegexp = New Regex(A_strPattern)
            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但在调用时执行到.Pattern = A_strPattern这一句时出错:
     未找到类型“Regex”的公共成员“Pattern”。 
    不知是什么意思,还是要请教一下!先谢了!