正则表达式在两个特殊字符之间获取文本

时间:2016-03-12 08:23:10

标签: vb.net

<%= NAME =%GT; 您的付款为<%= Payment =%> 问候 Rakesh Patel

1 个答案:

答案 0 :(得分:1)

尝试这样的事情......

Imports System.Text.RegularExpressions

Module Module1

Sub Main()
    Dim regex As Regex = New Regex("(?<=<%=)(.*?)(?==%>)")
    Dim m = regex.Match("<%=John=%> Your Payment is <%=10.00=%>")

    Dim matchCount As Integer = 0
    While m.Success
        Console.WriteLine(m)
        m = m.NextMatch()
    End While

    Console.Read()
End Sub

End Module