Tokenizer question

burak

Well-known member
Joined
Jun 17, 2003
Messages
127
Hello,

I will start working on a project where we have to parse a string and store the words and the number of times each word appears.

I know you can use the Split function to split a string into words and then Id have to savethe words and keep a track of how many times each one appears.

Does .NET already have a way to do this?

Thank you,

Burak
 
To save a word you can use the follow expresion:

(?<word>\w+)
after that you will have the result in the group of your Match object: Match.Gropus("word").value
If you want to save more than one word, the expresion should like :
(?<desc>\w+(\s+\w+)*)

In order to count how many times appears: Match.Count

I hope it help you,
Alvaro
 
Back
Top