このような新しい行を持つものをどのように一致させることができますか
"start does not work
end"
これはうまくいきます
「この作業を開始して終了」
これが私がコードを呼び出す方法です
Debug.Print(ParseData(RichTextBox1.Text, "start", "end"))
これは私が使用している機能です
20MB から 100MB の html ファイル、テキスト ファイルなどに対してこれを呼び出しているので、.Replace(Enviroment.Newline,"") は機能しません。
Function ParseData(strData As String, sStart As String, sStop As String)
Dim data As String
Dim i, j, iCount As Integer
Dim lines As New List(Of String)
lines.AddRange(strData.Split(Environment.NewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries))
For iCount = 0 To lines.Count - 1
i = lines(iCount).IndexOf(sStart)
While i <> -1
j = lines(iCount).IndexOf(sStop, i + sStart.Length)
If j <> -1 Then
If j > i + sStart.Length Then
data = lines(iCount).Substring(i + sStart.Length, j - (i + sStart.Length)).Trim
Debug.Print(data)
i = lines(iCount).IndexOf(sStart, j + sStop.Length)
Else
i = -1 'data not long enough
End If
Else
i = -1 'no "stop"
End If
End While
Next
Return iCount
End Function