How to do project search for All *Words* - not substrings

I was looking for a character by name where I had also written about their car.

So I used search with the “All Words” option, and search criteria “charName car”

Unfortunately that matched (and highlighted) documents with charName and “cared”, “carefully”, …

I tried a regex that at least finds the right documents,


but it highlights the whole span, which is OK but not exactly what I was looking for.

Q1 Is there a way to search for all WORDS and highlight only the words
Q" (bonus) Any way to highlight each word in a different colour?

I think “exact phrase” is what you need to search for. Not “all words”.
Include the space after “car”.

Thanks for the input but Exact Phrase is definitely not what I want. I want All Words because I know the charName and there is a mention of “car” in the document I’m looking for, but don’t know whether I am looking for “X’s car” ,“X got into the car”, “X leapt out of the way of the car”, or some other possibility.

1 Like

I see.
Sorry; I’m not halfway through my first coffee of the day.

@AntoniDol is good with stuff like that.

1 Like

No worries. Sorry to hear about the coffee shortage :wink:

Have you tried searching first for “CharName”, then within the found documents search for “car”?



1 Like

Make the RegEx ‘Ungreedy’. :wink: Check link above.

Thx. Alas not practical when its a major character, otherwise – I guess that would be viable for more rarefied searches.

Why ?
Search for your character’s name → save to collection.
Then search that collection for whatever you truly need (car).

OK, thanks. That link shows how my regex works, and I see the /gmU regex flags.

Turning off U to make it Ungreedy seems to be what Scrivener does by default. (I can see my OP was slightly ambiguous about matching “the whole span”, Scrivener does exactly what the Ungreedy suggestion aimed to achieve :slight_smile: spanning each occurrence of the the term pair, not from first hit to end of last hit)

i.e. Scrivener does this with the regex

What I am saying is I would have liked the highlighting of a search to be e.g. “Xander got into the car” and not “Xander got into the car”, but I’m beginning to think that is not possible/practicable.

(Having to search like this with a regex isn’t ideal. It would be better if Scrivener had a proper “All Words” option, because currently “All Words” is not an accurate description of how that option works IMO, it’s actually “All Sub-strings”)

For future reference, do you know how to manage the global regex flags in Scrivener?

Formatting, like highlighting or coloring a part of a text is a function RegEx never possessed, so the answer to that is: not possible.
Highlighting is what Scrivener does with the search results. I didn’t realize Scrivener doesn’t apply the RegEx flags like regex101 does, but *? makes the expression ‘lazy’ als in Not Greedy:


and that works for separating the results and Scrivener highlighting them separately…

1 Like

Easier way, is to search all words and use Character name and a space so have to seperate search terms .
ex John car and search will open pull up documents with both words and both words will be highlighted, Did just now in Scrivener 3 windows version.

Thanks for the thought! I also thought of that, unfortunately it doesn’t help if either term is before punctuation, regexes handle word boundaries better.

Yeah, I wasn’t looking to regex with high hopes for the highlighting, but it’s what Scrivener does with its search, and it’s what I would like… no harm in asking someone who knows more about such things, just in case!

Thanks also for the lazy/greedy refinement for use in Scrivener.

When I click your link to regex101, I see the flavor is PCRE2 (PHP >= 7.3). Is that the flavor supported by Scrivener?

Would this regex search be of any help? Not ideal, for sure, but it would highlight both words.


You could do the other search first


and then select the matching documents and do the simpler one within them.

Have you tried putting the word(s) in quotation marks? Or searching for Whole Words?

I thought I had, but I double checked just in case.

  • All Words, individual words in quotes: same as All Words, no quotes (that surprised me, it seems to de-quote)
  • “Whole Words” is not an option, “Whole Word” doesn’t work with two words separated by a space.
  • Adding a space after the second word has no effect
  • Some punctuation is ignored, e.g. “,” (comma), but not e.g. “!”, “.”, …?

Alas, all in vain

With All Words, what happens if you use your character’s full name (not in quotes) and then “car” in quotes. Based on my reading of the manual (specifically section 11.1.3 in the Mac version) that should work, but I’m not sure whether the Mac and PC search functions behave the same.

A+ for persistence, but even if Mac might be different it certainly doesn’t work on Windows - car in quotes i.e. “car” still hits e.g. (without quotes on the hits themselves) “career”, “cared”, etc.

pinging @kewms because the reply to you is not showing as such except in this post edit box. Strange.