---
title: "Discussion on \"Word counting in JavaScript: why text.split(' ') fails on Chinese, contractions, and extra spaces\" | Hashnode"
description: "Discussion on \"Word counting in JavaScript: why text.split(' ') fails on Chinese, contractions, and extra spaces\". Almost every \"word counter\" tool you find online does the same thing: split on spaces, count the pieces. That works for English — until it doesn't.\nTry it on a sentence with an apostrophe: \"don't worr"
url: "https://hashnode.com/posts/word-counting-in-javascript-why-text-split-fails-on-chinese-contractions-and-extra-spaces/6ad9b60a22c2cd8daf51f88b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Word counting in JavaScript: why text.split(' ') fails on Chinese, contractions, and extra spaces](https://toolstack-blog.hashnode.dev/word-counting-in-javascript-why-text-split-fails-on-chinese-contractions-and-extra-spaces?utm_source=hashnode&utm_medium=feed)

Almost every "word counter" tool you find online does the same thing: split on spaces, count the pieces. That works for English — until it doesn't. Try it on a sentence with an apostrophe: "don't worr

Oct 22 · 4 min read · toolstack-blog.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#webdev](https://hashnode.com/tag/webdev)
-   [#i18n](https://hashnode.com/tag/i18n)
-   [#productivity](https://hashnode.com/tag/productivity)

## Written by

[Li Yi](https://hashnode.com/@yison)

@yison

  
[View profile](https://hashnode.com/@yison)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
