|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Parsing a string - please helpHope that you can help me please? I have a string of the form: wordA wordB wordC wordD etc etc I want to de-duplicate it- that is, I want to remeove any repeated term (leaving only 1 occurance of all terms). What is the fastest way? I have lots of strings of this nature to parse! Should I use a arraylist perhaps? Does VB.NET have a dedicated method for doing this? Any comments/suggestions/code-samples much,. much appreciated. Thank you, Al Hi,
Maybe this will help. The hash table has a key for each item. When I add an item to the hash table I use the word as a key and value. I use the hash tables containskey method to see if the word is new. Dim strTest As String = "one two three four five one two three six five" Dim ht As New Hashtable For Each strWord As String In strTest.Split(" "c) Try If Not ht.ContainsKey(strWord) Then ht.Add(strWord, strWord) End If Catch ex As Exception Trace.WriteLine(ex.ToString) End Try Next Dim de As DictionaryEntry For Each de In ht Trace.WriteLine(de.Value) Next Ken ------------------ <almu***@altavista.com> wrote in message Show quoteHide quote news:1137757501.817537.91750@g43g2000cwa.googlegroups.com... > Hi everyone, > > > Hope that you can help me please? I have a string of the form: > > wordA wordB wordC wordD etc etc > > > I want to de-duplicate it- that is, I want to remeove any repeated > term (leaving only 1 occurance of all terms). > > What is the fastest way? I have lots of strings of this nature to > parse! Should I use a arraylist perhaps? Does VB.NET have a dedicated > method for doing this? > > Any comments/suggestions/code-samples much,. much appreciated. > > Thank you, > Al > Ken,
Thanks a million - this is super fast man. Hash tables rock! Merci, Al.
Compressing (zipping) files
dispose the login form vb.net tabpage copying dynamic Refresh questions Question on finding records in a ado.net vb dataset Save lines drawn in the picturebox as an lmage Job LastRunOutCome?? Maximized MDI childforms.... Anyone? installing an icon in the all users startup folder search within a arraylist |
|||||||||||||||||||||||