I’m trying to find the note with a certain word in the field “Expression”. For example : Expression:私. But this only work if the field is does not contains html. But in my deck it look like : <font color=“#aaaaff”>私</font> so it doesn’t work.
So how can I search for a word in a specific field containing html ?
I thought you only wanted to search for that word, even if html is present. If you elaborate on what you want to do, then we might be able to help better.
Sorry I thought doing like that was enough but I have too much result and I have some false positives.
I’m coding something that can detect words that you know and don’t (only for japanese). But as I said, in my deck words are written with html so if I use Expression:word it won’t work because it search for exactly that including the html. But I want to exactly search the text IN the html. So if I have this : <font color=“#aaaaff”>勉強</font> I want to exactly search for 勉強.
Anki is only able to search within formatting in the sort field you’ve configured. For example, if you add “example” to one of your fields, with the “exa” part in bold, this will not be matched when searching for example unless that field is the sort field. If a word is not formatted, or the formatting does not change in the middle of the word, then Anki will be able to find it in any field.
I guess yes. In my case no words are like example. All the characters are colored. With the previous solutions the problem was when searching for が it gives me a lot of word like 曲がる. (it’s an example). Maybe I could search for >word< but this won’t work with decks that don’t have html inside.
[I changed your HTML strings to be in a code-block so that the forum wouldn’t eat them up.]
From this I’m gathering that you want to search for the whole contents of the field – not just part of it – but to disregard any HTML, is that right?
First of all – you might be able to save yourself some grief by moving your color formatting to your card template/styling instead.
But for these examples, does searching on a word boundary work? [I’m not totally sure how word-boundary searches work with Japanese text.] Searching - Anki Manual Expression:w:私 Expression:w:が
This doesn’t work well neither.
But I found the solutions :
The problem with searching with Expression:*>word<* was that is didn’t work with fields without html inside.
So I just had to search for Expression:*>word<* OR Expression:word
And like that I can exactly search for the word with html and not.