本文整理匯總了VB.NET中System.Text.RegularExpressions.RegexCompilationInfo.MatchTimeout屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET RegexCompilationInfo.MatchTimeout屬性的具體用法?VB.NET RegexCompilationInfo.MatchTimeout怎麽用?VB.NET RegexCompilationInfo.MatchTimeout使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。
在下文中一共展示了RegexCompilationInfo.MatchTimeout屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Main
' 導入命名空間
Imports System.Reflection
Imports System.Text.RegularExpressions
Module Example
Public Sub Main()
' Match two or more occurrences of the same character.
Dim pattern As String = "(\w)\1+"
' Use case-insensitive matching.
Dim rci As New RegexCompilationInfo(pattern, RegexOptions.IgnoreCase,
"DuplicateChars", "CustomRegexes",
True, TimeSpan.FromSeconds(2))
' Define an assembly to contain the compiled regular expression.
Dim an As New AssemblyName()
an.Name = "RegexLib"
Dim rciList As RegexCompilationInfo() = New RegexCompilationInfo() { rci }
' Compile the regular expression and create the assembly.
Regex.CompileToAssembly(rciList, an)
End Sub
End Module
示例2: Example
' 導入命名空間
Imports CustomRegexes
Imports System.Text.RegularExpressions
Module Example
Public Sub Main()
Dim rgx As New DuplicateChars(TimeSpan.FromSeconds(.5))
Dim values() As String = { "Greeeeeat", "seed", "deed", "beam",
"loop", "Aardvark" }
' Display regex information.
Console.WriteLine("Regular Expression Pattern: {0}", rgx)
Console.WriteLine("Regex timeout value: {0} seconds",
rgx.MatchTimeout.TotalSeconds)
Console.WriteLine()
' Display matching information.
For Each value In values
Dim m As Match = rgx.Match(value)
If m.Success Then
Console.WriteLine("'{0}' found in '{1}' at positions {2}-{3}",
m.Value, value, m.Index, m.Index + m.Length - 1)
Else
Console.WriteLine("No match found in '{0}'", value)
End If
Next
End Sub
End Module
輸出:
Regular Expression Pattern: (\w)\1+ Regex timeout value: 0.5 seconds eeeee' found in 'Greeeeeat' at positions 2-6 ee' found in 'seed' at positions 1-2 ee' found in 'deed' at positions 1-2 No match found in 'beam' oo' found in 'loop' at positions 1-2 Aa' found in 'Aardvark' at positions 0-1