Find out number of words in a string with alot of special character : I need to find out the number of words in a string. However this string is not the normal type of string. It has alot of special character like &lt; , /em, /p and many more. So most of the method used in stackoverflow does not work. As a result i need to define a regular expression by myself.

What i intend to do is to define what is a word using a regular expression and count the number of time a word appear.
This is how i define a word.
It must start with a letter and end with one of this : or , or ! or ? or ' or - or ) or . or "

This is how i define my regular expression

    pattern = Pattern.compile("^[a-zA-Z](:|,|!|?|'|-|)|.|")$");
    matcher = pattern.matcher(line);
    while (matcher.find()) 
    wordCount++;



However there is error with the first line 
pattern = Pattern.compile("^[a-zA-Z](:|,|!|?|'|-|)|.|")$");

How can i fix this problem?