473,388 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Parsing a string - please help

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

Jan 20 '06 #1
2 1025
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
------------------
<al*****@altavista.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.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

Jan 20 '06 #2
Ken,

Thanks a million - this is super fast man. Hash tables rock!

Merci,
Al.

Jan 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Aleksandar Matijaca | last post by:
Hi there, I am in some need of help. I am trying to parse using the apache sax parser a file that has vaid UTF-8 characters - I keep end up getting a sun.io.MalformedInputException error. ...
6
by: Ulrich Vollenbruch | last post by:
Hi all! since I'am used to work with matlab for a long time and now have to work with c/c++, I have again some problems with the usage of strings, pointers and arrays. So please excuse my basic...
7
by: Lucas Tam | last post by:
Hi all, Does anyone know of a GOOD example on parsing text with text qualifiers? I am hoping to parse text with variable length delimiters/qualifiers. Also, qualified text could run onto...
6
by: P James | last post by:
Hi, My project has been running for 4 years in ASP/IIS (originally on NT4, then on Win2003 as of 1 year ago), using the following code to parse the request object using the XML DOM: Set...
29
by: zoltan | last post by:
Hi, The scenario is like this : struct ns_rr { const u_char* rdata; }; The rdata field contains some fields such as :
9
by: Paulers | last post by:
Hello, I have a log file that contains many multi-line messages. What is the best approach to take for extracting data out of each message and populating object properties to be stored in an...
1
by: kellysgirl | last post by:
Im not good at parsing strings....and Ive been driving myslef nuts This is what I need to do....use an if/else statement to validate thata delimeter has been selected. These delimeters being...
1
by: Sidhartha | last post by:
Hi, I am facing a problem while parsing local language characters using sax parser. We use DOM to parse and SAX to read the source. But when our application parses strings with local language...
9
nine72
by: nine72 | last post by:
Ok, so I have figured out how to parse an custom returned XML doc (actually a string that I made into a doc for testing). At this point I am attempting to integrate my parse routine into my main...
1
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.