當前位置: 首頁>>代碼示例>>VB.NET>>正文


VB.NET RegexCompilationInfo.MatchTimeout屬性代碼示例

本文整理匯總了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
開發者ID:VB.NET開發者,項目名稱:System.Text.RegularExpressions,代碼行數:23,代碼來源:RegexCompilationInfo.MatchTimeout

示例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
開發者ID:VB.NET開發者,項目名稱:System.Text.RegularExpressions,代碼行數:28,代碼來源:RegexCompilationInfo.MatchTimeout

輸出:

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


注:本文中的System.Text.RegularExpressions.RegexCompilationInfo.MatchTimeout屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。