私はこれを使用します:
Dim SearchString = "hello://thisismystring!?"
Dim ToFind = "://!?"
Dim ResultSpecial As String = ""
Dim ResultNormal As String = ""
Dim ChrList As New List(Of Char)
For Each c In ToFind
ChrList.Add(c)
Next
For i = 0 To SearchString.Length - 1
Dim c = SearchString(i)
If ChrList.Contains(c) = True Then
ResultSpecial = ResultSpecial & c
Else
ResultNormal = ResultNormal & c
End If
Next
Debug.Print("Resultnormal: " & ResultNormal)
Debug.Print("ResultSpecial: " & ResultSpecial)
必要なすべての文字を「ToFind」に書き込む必要があります。正規表現はさらにうまく機能しますが、面倒な場合があります。
リワークバージョン
Module Module1
Sub Main()
Dim SearchString = "hello://thisismystring!?"
Dim ToFind = "://!?"
Dim ResultSpecial As String = ""
Dim ResultNormal As String = ""
For Each c In SearchString
If ToFind.Contains(c) Then
ResultSpecial = ResultSpecial + c
Else
ResultNormal = ResultNormal + c
End If
Next
Debug.WriteLine(ResultNormal, "Resultnormal")
Debug.WriteLine(ResultSpecial, "ResultSpecial")
End Sub
End Module