A word counter that will update itself as the number of words in the textbox increases or decreases. If the words exceed the maximum length of 100, the count down number turns red in colour.
let words = input.value.match(/\b(\S+)\b/gi)
In the above pattern:
\b
Matches word boundaries i.e. starting or ending of a word\S
Not whitespace. Matches any character that is not a whitespace character (spaces, tabs, line breaks)+
Quantifier. Matches one or more occurrences of the preceding tokeni
Makes it case insensitive, andg
makes it do a global search instead of stopping at first match
Link to project: https://juel07.github.io/word-counter/
- HTML5
- CSS3
- JavaScript