Click here to Skip to main content
Click here to Skip to main content

Don't count spaces when counting words.

By , 18 Oct 2011

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

25 Oct 2011  
Jacobs76
 
I also use a Regex expression to count words, which returns the same number of words as MS Word. I wrap the Regular Expression in a String extension method to make it easy to use.public static class StringExtensions{ /// /// WordCounts Regular Expression /// ...
17 Oct 2011  
Pete O'Hanlon 3 alternatives  
 
Over the last couple of days I've seen numerous examples of people posting about how to count words in a sentence. Disturbingly, these postings recommend suggest counting the number of spaces in the sentence and use that as the basis of a word count.You may be asking why this is a problem. Well,...
6 Dec 2011  
FDW
 
This is less expensive:For any of the next strings, it gives 8:"Mr O'Brien-Smith arrived at 8.30 and spent \t $1,000.99"" Mr O'Brien-Smith arrived at 8.30 and spent \t $1,000.99""Mr O'Brien-Smith arrived at 8.30 and spent \t $1,000.99 "" Mr O'Brien-Smith arrived at 8.30 and...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

George Swan
Student
Wales Wales
No Biography provided

| | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 18 Oct 2011
Article Copyright 2011 by George Swan
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid