The java string split() method splits this string against given regular expression and returns a char array.
There are two signature for split() method in java string.
public String split(String regex)
public String split(String regex, int limit)
regex : regular expression to be applied on string.
limit :limit for the number of strings in array. If it is zero, it will returns all the strings matching regex.
array of strings
PatternSyntaxException if pattern for regular expression is invalid
The given example returns total number of words in a string excluding space only. It also includes special characters