I am using VB 9.0 to split a text file and then count occurrences of the term <sequence>
. Supposing I want also to count occurrences of the same term in a different format, e.g. <sequence
and then group them together such that I output the result to a text box, i.e.
txtMyTerms.Text=<sequence>+<sequence
How to do it? My current code is as follows:
Dim str As String = txtSource.Text
Dim arr As String() = str.Split(Nothing)
Dim searchTerm As String = "<sequence>"
'create query to search for the term <sequence>
Dim matchQuery = From word In arr Where word.ToLowerInvariant() = searchTerm.ToLowerInvariant() Select word
' Count the matches.
Dim count As Integer = matchQuery.Count()
txtMyTerms.Text = count.ToString()
I would try something like this. Note that string.Compare is more efficient than repeatedly calling ToLowerInvariant().