我想要完成的是在包含以下内容的哈希集中:
MSI (c) (AC:C0) [14:23:21:685]: Back from server. Return value: 1603
MSI (c) (AC:C0) [14:23:21:685]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (AC:C0) [14:23:21:685]: PROPERTY CHANGE: Deleting SECONDSEQUENCE property. Its current value is '1'.
Action ended 14:23:21: ExecuteAction. Return value 3.
MSI (c) (AC:C0) [14:23:21:685]: Doing action: SetupCompleteError
Action 14:23:21: SetupCompleteError.
Action start 14:23:21: SetupCompleteError.
找到返回值 3. 时;该行和它之前的行应该添加到第二个哈希集中。
MSI (c) (AC:C0) [14:23:21:685]: PROPERTY CHANGE: Deleting SECONDSEQUENCE property. Its current value is '1'.
Action ended 14:23:21: ExecuteAction. Return value 3.)
这可以作为正则表达式来查找该行和上面的行(据我所知),但到目前为止,我试图将这两行移动到下一个哈希集的所有操作都只移动包含返回值 3 的行。
Dim regrv3 As New Regex("(.*)\S\s(.*)Return value 3.")
相关代码:
Dim opened As New HashSet(Of String)(File.ReadAllLines(openfile))
Dim compa As HashSet(Of String) = New HashSet(Of String)
For Each StringMatch In opened
Dim m As Match
m = regrv3.Match(StringMatch)
compa.Add(m.ToString
Next
我是否遗漏了一些明显的东西,或者我是否需要某种复杂的索引来执行此操作?