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.
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 spanning each occurrence of the the term pair, not from first hit to end of last hit)
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:
(?:Xander.*?\bcar\b|\bcar\b.*?Xander)
and that works for separating the results and Scrivener highlighting them separately…
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.
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.