Searching for field length?

I would like to search for all cards where the search field, in my case “Hanzi”, has only one character. Maybe I’d like to search for different lengths in the future, but this is just to rehearse writing, one character at a time.
Since I didn’t find an appropriate function, I tried this:

re:"^.$"

which, according to regular expression rules, should give me all results with one character only. But the result list was empty. Now I’m not sure whether I did something wrong, or whether this is just not (yet?) supported.

This is with Anki 2.1.40 on Linux.

I just found that there is an add-on for Anki 2.0. I’ll have a look at that.

Your search is correct for finding notes with only one character. Try Hanzi:re:^.$.

Edit: Not relevant for your question, but for completeness’ sake: Searching for notes with a certain number of characters isn’t that trivial because the fields are joined internall by some character. So you would have to search for "re:^.{n}$" where n = [number of characters on the note] + [number of fields of the note] - 1.

2 Likes

Hi Rumo,
thank you for the tip! I tried without the quotes, then it worked.I was under the false impression that regular expressions needed to be quoted.