More curiosity than question: regex searching

regex and tab
Please forgive the outrageous pink – I’m still futzing with my settings. The HOT pink is “search results”. There’s tabs between each name (no paragraph breaks until I break for the next letter grouping.

My search terms: a\t
My settings: All; Regex; Search Binder Selection Only; Search Included; Search Excluded

My question: Why are the names “Jayda”, “Jadzia”, and “Ismena” not part of the search results? Or – are they? The results don’t always include the “a” – only highlighting the tab. I’m thinking this isn’t a ‘bug’ but probably a lack of understanding (on my part) of the entire search feature.

I’m on Win10, using Scrivener (64-bit). (I slapped the “feedback” tag on this since it was the only one that I felt fit.)

The fact that the tab itself is highlighted suggest they are, but that for some reason the “a” didn’t get the highlight. (?)

In case you don’t know of that website, you can test stuff here:

. . . . . . .

You know you can search for that without RegEx, right?

I did not know that! :exploding_head: Thank you (and for the link, too!)

1 Like

I think your selection color or current line color is interfering. Jayda also has a dotted line beneath the name. Maybe you should resolve the spelling issue first. It might be there’s an order to marking and coloring text. In Iliana, the a is also not highlighted, but has a dotted line…

Yes, this looks like a visual layering problem to me, rather than the search result itself being wrong. Basically text adornments like highlights are layered into the view, and so if one is on a higher layer than the other, it will obscure it. I would say ideally search highlights should always be on the upper layer and capable of obscuring everything (except maybe the text selection highlight, but I could see pros and cons for either approach there).

At any rate, you can test whether it is an actual discovery problem by inputting a replacement and clicking Replace All. For example:

Replace: (a\t)
With: [$1]

That should wrap square brackets around all of the found text, so if they all include the ‘a’ then it is finding things properly and only visually highlighting them in a way that obscures the highlight.

Incidentally, with RegEx (and most search criteria) the failure state for a match would result in no match at all, not a partial match. We can see this by how most of the tabs are not selected. The only way to get a conditional result would be with different syntax, like a?\t, which means the ‘a’ part is optional (zero or one, to be more technically precise). Include it in the match if it is found, but if it isn’t found, just include the tab. That would result in all of your tabs being selected, as well as all of the 'a’s if found and only if followed by a tab, but no other suffixing letters.

So, to the point of making search highlighting better, what kind of highlighting are you using for the places where the ‘a’ is not highlighting properly? Just a regular text highlight? It’s hard to tell from the screenshot alone.

My background is grey. The boxed pink around “Isidora” and “Jordana” is for a comment. The pale pink is current line highlight. The dotted line (dark purple-ish) is “misspelling” – I’m bad about adding names to my dictionary.

Next time I’m at my writing computer, I’ll see if adding “Jayda” and “Jadzia” to my dictionary solves my problem. Once again, you guys are the best!!!

1 Like

I can now confirm that the names which are flagged as “misspelled” (not in my dictionary) are the ones that don’t include the “a”. Now that I know that, I may have to actually tell Scrivener to learn all the names. LOL

You don’t necessarily have to do them all one by one by hand.
Perhaps search for an old post of mine with the keywords
dictionary - add - list - paste.

I explain how to batch add personal words to the dictionary.

If you can’t find the post, I’ll look for it when I get a few extra minutes.

You can also tell Scrivener to ignore the spelling for these specific words instead of telling it to learn them. But that’ll work only for that one project. And you’ll still have to do it one name at a time.

Is this the one?

The bottom part where you can paste them all at once.
One thing that I didn’t include in that post (I only found out later) is that I think you have to make sure your words don’t have curved apostrophes or single quote marks if any. (Although perhaps it doesn’t matter since pasting them in notepad. If the operation fails, that might be one thing to check for.)

And thanks for locating the post.
I bookmarked it (this time, lol).