Regex searches only in front card?

I’d like to create a very simple regex search which searches exactly one simple word in a field.

Example:
front card: test1
back card: test2

The search
"re:^test1"
succeeds.

But the search
"re:^test2"
has no results.

I think that there are invisible characters before test2 because
"re:^.*test2"
works.

I came to this because I wanted to find spaces before the word. Therefore I used ^ (beginning of line):

"re:^ \w"

Of course this works only for spaces found in front card, too. Spaces at the beginning of back card are not found.

I think this regex searched in front and back in the last version before 2.24.0, but perhaps I overlooked it and it searched also only in front.

So, how can I search in back card for a single word with a space before the first letter? And why does the regex search differ between front and back card?

BTW With the end of line symbol ($) it’s vice versa:
"re:test2$" succeeds.
"re:test1$" fails.
"re:test1.*$" succeeds.

Thanks for clarification.

Thorsten

So, how can I search in back card for a single word with a space before the first letter?

I think you should just limit your search to the specific field that is on your card back. From your post I’m assuming you’re using the default Basic note type that has just the two fields called “Front” and “Back”. Then the search "Back:re:^ \w" should do the trick.

And why does the regex search differ between front and back card?

Dunno why that difference happens when you regex-search globally without limiting to a field like that. I always limit searches to a specific field.

Fields are separated by \x1f (What is the field separator character when performing regex search (i.e. re:) in the browse window? - #2 by mbrubeck).

So the note you made is basically ^test1\x1ftest2$.

Thank you for your help!

This works for trimming:

  • Find spaces at the beginning of card entries:
    (front:re:^\s+) or (back:re:^\s+)

  • Find spaces at the end of card entries:
    (front:re:\s+$) or (back:re:\s+$)

Thorsten