Conversion of Cloze NT to Basic NT without retaining syntax

I am trying to figure out how to convert from Cloze notetype to Basic notetype without retaining syntax. I know the conversion process (select notes, change notetype, select basic), however, once the process is complete, the syntax {{cn::answer}} is retained in the basic cards.

Is there a way to completely remove that syntax when converting? I know I can mass select all basic cards and do “Find and replace” function, however there is a caveat to this: some cards have cloze hints (ex: {{cn::answer::hint}}). If I do find and replace, these cloze hints will be converted to answer::hint or answerhint or answer hint.

As far as I know, there is no built-in way to automatically remove cloze syntax in Anki. However, you could use the “Find and replace” function in combination with regex.

E.g. the following steps seem to work fine on my end (but I recommend doing a backup first, just in case):

  1. First, use Find and replace to remove the cloze syntax + the hints of all clozes that have a hint. I am assuming that you’re not interested in preserving the hints at all.
    Find: \{\{c[0-9]+::(.*?)::(.*?)\}\}
    Replace: $1
    Treat input as regular expression: yes

  2. Then, remove the cloze syntax of all clozes that do not have a hint.
    Find: \{\{c[0-9]+::(.*?)\}\}
    Replace: $1
    Treat input as regular expression: yes


That worked beautifully. Thank you so much!

1 Like

So I started having some issues with that RegEx. When I follow those steps, I have noticed some notes actually tend to retain some parts of the syntax as such:
{{c1answer and answer}} and sometimes hint}}

After looking around, I came about this add-on: Remove Cloze Hotkey and Button [Link] Credit: @glutanimate

I looked into the code, and noticed the following RegEx:
So I decided to try this out on Find and Replace Menu, and use $2 as replace value. It seems to recognize both syntax with and without hints without doubling the steps. I can batch select cards, and use that regex, since the 3rd capture group is followed by ? which matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy).
It works with images as well.

If @glutanimate can implement this in a way that can allow batch selection of cards, that would be cool implementation within their add-on.