I understand the basis of Regex (regular expressions to the uninitiated), and importantly how to get ChatGPT to help with syntax generation. I’m wondering if there’s a way to include a label name or status in a Regex search? Given these fields are particular to Scrivener, it may not be possible?
You can’t identify the label or status as part of the regular expression but you can limit the project search scope to label or status by selecting them from the magnifying glass dropdown menu in the project search bar; holding the ⌥
key will allow you to add additional “Search In” scopes, so you could run your search on both label and status at once if that’s what you’re after.
If what you’re really after is results that match both some specific term in the main text, say, as well as a particular status or label, and those aren’t unique (i.e. the label term might also appear in the main text), you’ll need to do a sort of multi-pass search, first creating a results list that matches one criterion and then further filtering that list for the second. There are two ways to do this.
Double project search
- Run the first project search, then
⌘A
within the results list to select them all ⌥⌘R
(Navigate ▸ Reveal in Binder
) to switch to the full binder list with those results still selected- Run the second project search but tick the option in the search menu to Search Binder Selection Only
Corkboard/Outliner Filtering
- Run the initial project search, then load the results onto the editor by clicking the
↪
button in the search results header; switch to Outliner or Corkboard view as you prefer - With focus in the editor, use
⌘F
to bring up the filtering options at the top - Use these options to run the second search to filter the initial results
The filtering options are more limited than the project search, so which works better for you will depend partly on what sort of search you’re trying to run. You can use RegEx for both; though; click the magnifying glass in the filter field to set it there.
@davidbrewster You don’t explain exactly what you want to do.
Anyway, label and status are actually just words (a sequence of characters). Scrivener can theoretically search for as many words as you want. For example, if you give the label green a unique name like l:g, then you can search for this “word” as you would for any other word.
This search will find all documents with the word “test” that have a green label.
In this way, the search can be combined in any way you like.
Thanks for your useful responses. No, I wasn’t clear about my use case. What I had in mind was searching for documents with a particular label that did not have the status ‘Done’. In practice, as this is not something I do often, the two-step approach is a perfectly workable workaround. That said, I like the idea of creating unique label names – I’ll use that in future.
Assuming your Status Done is s:d and your label is l:g
This search should find all documents with label green that do not have the status Done