I tried but was unable to reproduce the OP’s issue.
However, there are 3 unusual behaviors that I saw with Anki desktop Find/Replace:
- The behavior of most other Find/Replace functionality that I’ve seen in other apps is that an empty Find field matches only empty fields. (Basically, the equivalent of matching ‘
^$’, or more accurately, matching ‘^()$’, with the Replace operation replacing the empty match group ‘()’.)
However, in Anki it appears that an empty Find field matches ‘[^$.]()[^$.]’, replacing the empty match group ‘()’.
Some testing with Find: ‘’ (empty field), Replace: ‘x’
Before, After:
‘’, ‘x’
‘a’, ‘xax’
’ a’, ‘x xax’
'a ', ‘xax x’
‘a’, ‘x xax x’
‘ab’, ‘xaxbx’
‘a b’, ‘xax xbx’
‘a b’, ‘xax x xbx’
‘a b’ (2 spaces between a and b), ‘xax x x xbx’
- It is possible to enter space characters into a Note field in 2 ways:
a. HTML editor
b. Search and replace
Normally, when you enter space characters in a field, Anki converts them into ‘ ’. However, if you use either of the 2 methods above, you can enter space characters into a field.
When a field contains only space characters (and the HTML editor UI is hidden), the field appears to be empty. Users can be tricked into thinking a field is empty, when it actually isn’t. (Basically, Anki is hiding leading and trailing spaces.)
- These two behaviors interact with each other when you intend to find and replace a blank field, the field looks blank, but it actually contains space characters.
Before, After:
’ ’ (1 space character), ‘x x’
’ ’ (2 space characters), ‘x x x’
’ ’ (3 space characters), ‘x x x x’
I was able to produce the field value shown in the OP’s post by this sequence:
-
Starting with an entirely empty field.
Field: ‘’ (empty field)
HTML editor: ‘’ (empty field)
-
Find: ‘’ Replace: ‘2 1 7’
Field: ‘2 1 7’
HTML editor: ‘2 1 7’
-
Find: ’ ’ Replace ‘2 2 2’
Field: ‘2 2 2 2 2 2 2 1 2 2 2 7 2 2 2’
HTML editor: ’ 2 2 2 2 2 2 2 1 2 2 2 7 2 2 2’