I get false positives in the Browser when searching with regex

I get several false positives on browser searches using regular expressions. As per the Anki manual, a search:of Country:re:- should yield a list of all my notes where the Country field has a dash “-”. It does that but in addition it yeads several notes where this fiel does not have a “-”. Any help would be greatly appreciated.

Can you provide some examples of the “Country” Field contents for the false positives? Preferably, the HTML source.

2 Likes

Definitely the HTML – since there’s so much of CSS that uses -'s. You can see that underlying HTML by clicking < > above the field.

For “Turkiye”
<span style="color: rgb(0, 29, 53); background-color: rgb(255, 255, 255);">Turkiye</span>

The HTML from clicking “<>” over the Country field does not paste here for some reason. BTW I also tried the following search with the same results: Country:re:\D+-\D+

The forums support HTML formatting so you have to paste it in a code block like this:

```
Text goes here
```

[I edited your post for you to code-block your HTML.]

As you can see, there’s your hyphen.

What were you trying to search with that? I would think that ± is that literal character. Do you have that in your “Country” field?

3 Likes

My Anki browser search," \D+" followed by" -\D+", gets revised in this forum as “+” superimposed over the “-” sign.

My original intent was to find a search for hyphens in the visible content of my field named Country.

Ah! That makes more sense. [I edited your post to code-block that as well.]

Yes, that would match on the same CSS hyphens.

One way you could accomplish this is to export to a text file without HTML included, and search that.

1 Like