number_of_words

v10.13.0

Count the number of words in some text. This filter takes an optional argument to control the handling of Chinese-Japanese-Korean (CJK) characters in the input string:

  • Passing 'cjk' as the argument will count every CJK character detected as one word irrespective of being separated by whitespace.
  • Passing 'auto' (auto-detect) works similar to 'cjk' but is more performant if the filter is used on a variable string that may or may not contain CJK chars.

Input

{{ "Hello world!" | number_of_words }}

Output

2

Input

{{ "你好hello世界world" | number_of_words }}

Output

1

Input

{{ "你好hello世界world" | number_of_words: "cjk" }}

Output

6

Input

{{ "你好hello世界world" | number_of_words: "auto" }}

Output

6