Link to home
Create AccountLog in
Avatar of tia_kamakshi
tia_kamakshiFlag for United Arab Emirates

asked on

Word Count using Regular Expression

Hi,

How do we Word Count in Text from regular Expression. I am working on C#, ASP 2.0

Can we find and Replace Text using in Regular Expression and finally gives replace text count


public static int WordCount(string orignalTxt, string strTextToFindAndCount, string strReplaceText)
{
      int wordReplacedCount =0;
      return wordReplacedCount;
}


Many Thanks
ASKER CERTIFIED SOLUTION
Avatar of ddrudik
ddrudik
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of tia_kamakshi

ASKER

Thanks for your help.

But I need to put about 25 MB of file to find the word count.

Is the Regular Expression feasible. If yes can you please help me with the code which suits me in the method

public static int WordCount(string orignalTxt, string strTextToFindAndCount, string strReplaceText)
{
      int wordReplacedCount =0;
      return wordReplacedCount;
}


Thanks again
I guess I would have you test it with your source file.
you can do with 25 MB, just read the file line by line, and use the code that ddrudik suggested, accumulating the counts.