Count words Using Regular Expression
Saturday, June 28th, 2008
1. Html Code
2. Dividers
3. Extra spaces + new lines
I used regular expression to filter the strings. For this purpose I created two functions:
RemoveExtraSpaces – Remove extra spaces from string. The function allow only one space between each word.
CountWords – The function return number of words in a string. It use the function RemoveExtraSpaces and use regular expression to remove HTML Code , New Lines and Dividers.
///
<summary>
///
///
/// <param name=”s”>This is the string that we want to check
/// <returns>Fixed String</returns>
private
}
///
///
///
/// </summary>
/// <param name=”strText”>The text that we want to check
/// <returns>number of words
public
}
