Search in field that contains linebreaks

n8abx9y2qg's Avatar

n8abx9y2qg

25 Sep, 2019 10:42 AM

I usually search wtih
myfieldname:_*mysearchterm
when I know the field and also know that the word I want does not come first.

By chance I noticed that this no longer works if the word I am looking for appears after a linebreak.
Example:
first meaning;
entirely different meaning hence linebreak

mysearchfield:_*different

does not find anything.

Don't get me wrong, the search functions in Anki are fantastic. I wonder if there is something I can do to get even this specific search to work for words that occur very frequently. Thanks for any advice!

Version 2.0.51
Qt 4.8.4 PyQt 4.10
(Not sure if my add-on setup is portable to 2.1)

  1. Support Staff 1 Posted by Damien Elmes on 25 Sep, 2019 10:14 PM

    Damien Elmes's Avatar

    Can you reproduce the problem in the latest Anki version?

  2. 2 Posted by n8abx9y2qg on 22 Oct, 2019 05:01 AM

    n8abx9y2qg's Avatar

    Hi, thanks for replying.
    Sorry for answering so late: Yes, the exact same thing occurs on
    Version 2.1.15 (442df9d6)
    Qt 5.12.1 PyQt 5.11.3

    I found out that it doesn't occur if I add another *, i.e.
    myField:_*mySearchTerm* or
    myField:*mySearchTerm*

    Whereas without the second * the card is not found - which is weird because mySearchTerm is in fact the very last string in the myField entry (there is not even a space or other whitespace char following).

    Thanks again, great programme, great search options, and plenty of workarounds for this.

  3. Support Staff 3 Posted by Damien Elmes on 22 Oct, 2019 10:05 PM

    Damien Elmes's Avatar

    Perhaps I'm not understanding you? Field searches must be an exact match, so if the content you're searching for is preceded by or followed by other content, you'll need a * at the start and/or end.

  4. 4 Posted by n8abx9y2qg on 29 Oct, 2019 08:35 AM

    n8abx9y2qg's Avatar

    Yes, absolutely. The COMPLETE field content is

    something
    mySearchTerm

    with nothing whatsoever after mySearchTerm (no space, no linebreak, no char).
    So why would I need to add an asterisk AFTER mySearchterm if there is nothing whatsoever after it that could be matched?

    "*mySearchTerm"
    and
    "_*mySearchTerm"
    both are exact matches for the complete field content.

    Sorry if I do not explain well, what the question is. Please let me know if I misunderstood something.

  5. Support Staff 5 Posted by Damien Elmes on 29 Oct, 2019 10:07 PM

    Damien Elmes's Avatar

    Did you check that's the case using the HTML editor inside the editing screen? There may be HTML you can't see.

  6. 6 Posted by n8abx9y2qg on 05 Dec, 2019 05:37 PM

    n8abx9y2qg's Avatar

    Yeah, that must be the answer. Anki seems to insert a new <div></div> when inserting a linebreak in a field (even if the original content had no HTML at all). Instead of just putting <br/> in the position of the linebreak. That discovery makes me a tiny bit worried about the HTML that is produced (first line no div, second line autmatically placed in div).

    Thanks for figuring it out. This had me really puzzled :) Also, the solution is easier to remember when understanding why it happens: Always put an extra * at the end, there might be HTML.

  7. n8abx9y2qg closed this discussion on 07 Dec, 2019 04:54 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac