House not Household

Have fun! :crazy_face:

2 Likes

Ah, now I see how it would be done. Interesting :slight_smile:

“Have fun! :crazy_face:

would you advise me not to learn RegEx?

No, to rejoice in the power of RegEx.

2 Likes

Here’s the RegEx from Nisus Writer Pro that does what you want:

(\bhouse\b|\bgarden\p{Lower}*\b)

tested against the following sentence

They had a huge house, with a household staff of 20, and 4 acres of garden managed by a team of ten gardeners.

the \bs mark the search boundaries, so eqivalent of ‘whole word’; the \p{Lower}* means “any number of lower case characters”. So this is either find “house” or any other word beginning “garden” with zero or any number of characters after it.

Disclaimer: this is the dialect of RegEx used by Nisus Writer Pro (Mac only); I haven’t tested it in Scrivener, and I don’t know if Scrivener uses the same dialect — as they are both based on the same text engine on the Mac, they might well, but that may not be true for Windows Scrivener.

Anyway, I hope that helps.

:slight_smile:

Mark

P.S. In the NWP dialect, the ( and ) mean “capture the enclosed”, i.e. remember it for further processing. If all you want is to find instances but not have them remembered, you can leave them out. As always, just experiment!

P.P.S. Works in Scrivener on the Mac!

For that number of documents, yes. Beyond this specific example, over the long term you’re going to need a general purpose Boolean search tool. In the Scrivener context, that means RegEx.

1 Like

As my RegEx expression works in Scrivener on the Mac, even though I’ve only tested it on that short sentence which illustrates the problem as originally set, it should work across a full project. I cannot test it on Windows and I don’t know how well Project search works on Windows.

Mark

Hi

I have a Mac and can confirm that Mark’s RegEx works.
Now that I’ve taken a closer look at Scrivener’s search function, the overall picture ist rather disappointing.

The “Whole Word” option only allows searching for exactly one word. So you can’t search for “house” and “garden”. Almost useless.

All Words: Is very good, but inaccurate and finds too much.

Any Word: Is completely useless in my opinion.

Exact Phrase: Is useful. Searches for exact words in a sequence.This is how “Whole Word” should work, even if the words are not in a sequence.

With “-” words can be excluded from the search. Good idea. But this works only with one word. Almost useless.

RegEx: very powerful. But hardly suitable for normal users.

And then there are some other tricks, which are more or less useful, but not intuitive.

Conclusion: Scrivener is great, but the search function could be much better. I don’t know if I’m the only one who thinks so. If I have misrepresented something, please correct me.

Compared to what? Scrivener is not intended to be a DevonThink replacement or competitor. I wouldn’t expect its search features to compare to DevonThink’s, any more than DevonThink’s writing features compare to Scrivener’s.

2 Likes

Just my opinion, but with regular expressions, Scrivener (and other software) really don’t need to have more complicated edge cases. There are several readily available regular expression libraries for developers to use (assuming they aren’t already incorporated into the development framework) and once you know one flavor of regexs, you’ve opened a whole new world into searches, replacements, and so much more.

I prefer to learn something that I can build on across multiple environments, not a specialty tool that only works in that one case/program but leaves me having to start from scratch when I move to a new program. I started learning regular expression syntax back in my UNIX admin days in the '90s when I was still writing Perl and Bourne shell scripts, and almost none of that experience and knowledge has gone to waste. I can leverage almost all of it with just about any modern program – because almost all of them offer some level of regex compatibility.

4 Likes

Can I ask what flavour/dialect of RegEx Scrivener uses? I’d obviously be most interested in the Mac version, though others might be interested to know what the Windows version uses.

Mark

1 Like

“Scrivener uses the stock RegEx engine supplied by the Mac, which uses a the UTF-8 compatible ICU guidelines. ICU is mostly compatible with PCRE, which is considered to be the standard for extended regular expression syntax.” (Scrivener Manual, 11.7)

And for Windows: “Scrivener uses the QT5 Regular Expression engine, and is fully PCRE compliant. This is considered to be the standard for extended regular expression syntax.” (11.2.1)

3 Likes

Thanks for that. Stupidly, I didn’t think to look there!

:roll_eyes:

Mark

2 Likes

I used this nice guide and helped me a lot
h t t p s ://writersinthestormblog.com/2018/08/3-ways-to-search-in-scrivener-3/

1 Like

3-ways-to-search-in-scrivener-3