我想将此文本数组分为3个部分
示例文本:
假期人身伤害$ 10,000
财产损失$ 100,000
第三方车辆损毁$ 10,000 市区内的财产损失为$ 100,000
每份保单$ 20,000
它应该这样组织:
注意:
前后的单词数不一致。只有$
符号是一致的。
答案 0 :(得分:0)
您可以使用它,代码可能看起来很复杂,但是通过研究您会理解它
Dim test As String = "your string here"
'Split the text into lines and store in array
Dim split1() As String = Split(test, vbLf)
Dim split2() As String
Dim split3() As String
For x As Integer = 0 To Ubound(split1) - 1
split2 = Split(split1(x))
For y As Integer = 0 To Ubound(split2) - 1
If split2(y).StartsWith("$") Then
For z As Integer = 0 To y - 1
split3(0) &= split2(z)
Next
split3(1) = split2(y)
If y < Ubound(split2) - 1 Then
For a As Integer = y + 1 To Ubound(split2) - 1
split3(2) &= split2(y)
Next
End If
End If
For b As Integer = 0 To 2
Console.WriteLine(split3(x))
' or you could use Textbox.Text += split3(x)
' Do whatever you want with those values here
'split3(0) = Text before $ sign
'split3(1) = Text with $ sign
'split3(2) = Text after $ sign
Next
Next
Next
答案 1 :(得分:0)