Return to Snippet

Revision: 41132
at February 12, 2011 12:52 by Sootah

Initial Code
using System.Text.RegularExpressions;

        public int WordCount(string txtToCount)
            string pattern = "\\w+";
            Regex regex = new Regex(pattern);

            int CountedWords = regex.Matches(txtToCount).Count;

            return CountedWords;

Initial URL

Initial Description

Initial Title
wordCount - RegEx count the number of words in a string

Initial Tags

Initial Language