First, you did not actually explain what the problem is. Do you need a program that parses a string to check how many words of a certain length are there?
How much will you pay?
Code:using System; using System.Text.RegularExpressions; using System.Text; using System.Collections; namespace ParserNamespace { class Class1 { public int[] ParseString(String text) { int [] vector = new int[6]; Regex reg = new Regex(" |, | ,|,"); StringBuilder sbuilder = new StringBuilder(); foreach(string s in reg.Split(text)) { if(s.Length<6) vector[s.Length-1]++; else vector[vector.Length-1]++; } return vector; } [STAThread] static void Main(string[] args) { Class1 test = new Class1(); int [] results = test.ParseString("this is just a simple text,nothing more, nothing less"); int i=1; foreach(int val in results) { Console.WriteLine("Words of length {0} : {1}",i++,val); } } } }




Marius Bancila
Reply With Quote