Anki Forums

Word Count of a given field — any progress?

I want to split up a huge deck into a word/phrase and a separate sentence deck (arbitrarily, a sentence is anything with more than 5 words).

So let me get this clear: You have this huge deck, there are a lot of notes / cards in it. They have the same note type. You want to sort them by “words” vs “sentences”. Whether a note belong to the “words”-type or “sentences”-type depends on the count of words in a specific field.

Is that correct?

Yes, that’s correct. If there isn’t enough time to review all cards, I want to concentrate on single words or short phrases, b/c they are more important to learn.

I have a suggestion: I am a developer, so I know my way around my text editor.

You could

  1. Go to the deck which has all these cards
  2. Click the small wheel to the right of the deck name
  3. Click Export
  4. Select “Notes in Plain Text” as the Export format
  5. Check "Include tags, uncheck Include HTML and media references
  6. Click “Export…”

What you will get is a file with the “.txt” ending. Upload this text file up here.
I will do my magic, and put a tag (let’s say “sentence”) to all notes which fall under the definition of “sentence”-type, as we discussed above.

I will then give the file back to you, and you can reexport it, thus adding the tag to all those notes.

You will need to tell me the position of the field which contains the word/sentence however. So, when opening the editor in Anki, on which position the field is (first, second, etc.).

1 Like

Thanks very much; that’s kind of you …

However, I’d be after a more general, permanent solution for getting the word count of a field; I remember, in the past, other users asking for this as well.

I will do my magic,

How about an addon, that would allow sorting by word count in Anki’s card browser … :wink:

Otherwise, the issue is not that pressing for me right now; so I’ll keep watching …

Again, thanks!

You can use Regular Expressions to search for note fields with a certain number of words:


This matches notes where field contains between x+1 and y+1 words (a “word” being a string of one or more non-whitespace characters delimited by whitespace or the start or end of the field string). So for your purposes, you would replace x with 4 and omit y.
This can also be further refined to ignore HTML tags or split words on an apostrophe. RegEx are really awesome. :slightly_smiling_face:


How could I forget, that Anki also has regex capabilities now. :sweat_smile:

Thanks very much; that does the trick for now … This even ignores the hint words within the curly cloze brackets.

Didn’t know RegEx could be used in the Card Browser itself …

This can also be further refined

Fortunately for a noob like myself, one doesn’t have to understand everything to be able to use everything :wink: