我正在尝试创建我期望从子程序 (GetAllPosition) 获得的内容。我不知道RsultOfPostionAndLength
在代码中哪里使用才能获得预期的输出
我对()的输出的期望RsultOfPostionAndLength
:
MultiSplit 的用法{"C", "B", "A"}
为: 55-5 '}666[' 61-5']777(' 67-3')8[' 71-6']hhhy('
MultiSplit 的用法{"A", "B", "C"}
为: 27-6 ']1111{' 34-4'}22(' 39-7')33333{' 47-3'}4{' 51-3 '}5{' 55-5'}666[' 78-4')99{' 83-5'}999['
Dim RsultOfPostionAndLength As List(Of String) 'Pattern is Position of String And Length Of Find
' 'MultiSplit' For {"C", "B", "A"} is: 55-5 '}666[' 61-5']777(' 67-3')8[' 71-6']hhhy('
' 'MultiSplit' For {"A", "B", "C"} is: 27-6 ']1111{' 34-4'}22(' 39-7')33333{' 47-3'}4{' 51-3 '}5{' 55-5'}666[' 78-4')99{' 83-5'}999['
Sub Setup()
Dim inString As String = "}666[]777([}666[]777(]00[A]1111{C}22(B)33333{C}4{C}5{C}666[A]777(B)8[A]hhhy(B)99{C}999[A]101010}666[]777("
Dim MultiSplit As String() = {"C", "B", "A"}
GetAllPosition(1, inString.Length, inString, MultiSplit, 0)
End Sub
Sub GetAllPosition(LastIdx As Integer, LastLen As Integer, inString As String, MultiSplit As String(), Level As Integer)
Dim spl As String() = Split(inString, ",")
Dim body As String = Mid(inString, LastIdx, LastLen)
'Dim LastIdx As Integer = spl(0)
Dim results As New List(Of String)
Dim Find As String = MultiSplit(Level)
Dim last As Integer = LastIdx
Dim index As Integer = -1
Do Until body.Length <= index
index = body.IndexOf(Find, index + 1)
If index = -1 AndAlso body.Length > last Then
index = body.Length
End If
Dim lenTexxt As Integer = Math.Abs(last - index) + 1
Dim part1 As String = Mid(body, last, lenTexxt)
Dim part As String = Mid(inString, last, lenTexxt)
Dim b As Boolean = MultiSplit.Skip(Level + 1).All(Function(c) part.IndexOf(c, comparisonType:=StringComparison.OrdinalIgnoreCase) > -1)
If b Then
results.Add(last & "," & lenTexxt & "," & part)
End If
last = index + 2
Loop
Level += 1
For Each g In results
Dim spl2 As String() = Split(g, ",")
GetAllPosition(spl2(0), spl2(1), inString, MultiSplit, Level)
Next
End Sub