... databox.text(以下のサンプルコードから)は、以前にプログラムに入力された結合語(ドメイン名)の大きなリストを含んでいます。各行に1つずつあります。文字列の視覚的な基本検索テキスト、適切な場合の結果を表示
thepeople.com
truehistory.com
workhorse.com
whatever.com
neverchange.com
...
は、次のコードは、以下のtlistfiltered.txtするdatabox内のテキストを保存した後、「リスト内の項目のいずれかを含むすべての行を取得するtlistfiltered.txt検索編曲:のように、この例では、最初に見えます() "を実行し、結果をlistview(lv)に取り込みます。これはうまく動作しますが、結果は次のようになります。
thepeople.com
truehistory.com
neverchange.com
...
しかし、私は必要なの結果は次のようになりますので、「見つかった文字列」(ARRから()リストが適切な場合になることです。
thePeople.com
trueHistory.com
neverChange.com
ここで
コードです....
Dim s As String = databox.Text
File.WriteAllText(dloc & "tlistfiltered.txt", s)
databox.Clear()
Dim text2() As String = System.IO.File.ReadAllLines(dloc & "tlistfiltered.txt")
Dim arr() As String = {"people", "history", "change"}
For index1 = 0 To arr.GetUpperBound(0)
Dim YesLines() As String = Array.FindAll(text2, Function(str As String)
Return str.Contains(arr(index1))
End Function).ToArray
databox.Visible = True
For index2 = 0 To YesLines.GetUpperBound(0)
Dim match As String = (YesLines(index2)) & vbCrLf
databox.AppendText(match)
Next
Next
s = databox.Text
File.WriteAllText(dloc & "tlistfilteredfinal.txt", s)
databox.Clear()
domains = (From line In File.ReadAllLines(dloc & "tlistfilteredfinal.txt") Select New ListViewItem(line.Split)).ToArray
lv.Items.Clear()
My.Computer.FileSystem.DeleteFile(dloc & "tlistfiltered.txt")
My.Computer.FileSystem.DeleteFile(dloc & "tlistfilteredfinal.txt")
BackgroundWorker1.RunWorkerAsync()
End Sub
がその場でこれを行う方法はありますか?私はは、StrConvなどを試してみましたが、それだけで適切な場合に行全体を変換します。私は唯一の "欲しいです発見された "単語が含まれているverted ....
編集:
databox.Visible = True
For index2 = 0 To YesLines.GetUpperBound(0)
Dim match As String = (YesLines(index2)) & vbCrLf
Dim myTI As System.Globalization.TextInfo = New System.Globalization.CultureInfo("en-US", False).TextInfo
If match.Contains(arr(index1)) Then
match = match.Replace(arr(index1), myTI.ToTitleCase(arr(index1)))
'StrConv(match, vbProperCase)
databox.AppendText(match)
End If
Next
および所望の結果を得た:
をの答えを@soohoonigan見た後、私はこれに
databox.Visible = True
For index2 = 0 To YesLines.GetUpperBound(0)
Dim match As String = (YesLines(index2)) & vbCrLf
databox.AppendText(match)
Next
Next
を編集しました!
ありがとう!私はコードを編集しました: – t4nk