How to get word/character count with Text Blaze

Any self-respecting text editing app has a word/character count feature nowadays. But sometimes, you'll be using Text Blaze to fill out a form, and you'll come across a text field that has a word/character limit, so you want to avoid exceeding that while you're Inserting your snippet.

Here are three snippet bits that you can use for that.

Just copy whichever one you want to use, paste it inside your snippet, and change the variable names to match the name of the formtext or formparagraph you want to use it on.

Here are the snippets.

Word count:

{formparagraph: name=data; default=the quick brown fox jumped over the lazy dogs}
{=count(split(data, " "))}

Character count including spaces:

{formparagraph: name=data; default=the quick brown fox jumped over the lazy dogs}
{=len(data) }

Character count excluding spaces:

{formparagraph: name=data; default=the quick brown fox jumped over the lazy dogs}

{=count(extractregexall(data, "[^\s]")) }

Hope this helps :slight_smile:

EDIT: In my enthusiasm, I hadn't realized that the second and third snippets could be A LOT simpler.

Big thanks to @scott for pointing out the error of my ways :blush:

I've now updated the snippets accordingly. Enjoy!

As an added note, the third snippet is using extractregexall() to extract all characters that are not white space (represented by [^\s])