Came across this gem online when semi-automating the editing of my MS:
Run a RegEx search in Scrivener using this string and it will find all the consecutively repeated words you’ve accidentally created during your writing and editing process (e.g. “the the”):
(?-i) makes the query case-sensitive and saves clicking into the dropdown and toggling. (There’s also a bug with toggling case-sensitivity when you have multiple projects open. This sidestep the bug entirely.)
[a-z]+ is useful for more complex searches where you don’t care what word is in that place. It’s not really a word, but a string, so can be used to compose words (e.g. [a-z]+ly).
Not only did I learn about using the RegEx search in Scrivener (which as a RegEx neophyte I’d never done) but I found more than a dozen instances of repeated words … I can see a whole new world of possibilities here …
I need to look into auxbuss’s suggestions as well! Thank you for your suggestions!
Are there resources for neophytes either of you would recommend to get started with RegEx?
Given the flexibility and power of johnnyalpha’s RegEx snippet as an example, is there perhaps a book or listing of RegEx ‘recipe’ snippets promulgated anywhere … I can imagine such a listing could be very helpful for writers, et al.
Like Matryoshka dolls, Scrivener has so many layers … the more one learns, the more there is to learn … I am in awe at the depth the application continues to show …
Thanks again,
scrive
Update: A simple search for “RegEx ‘recipe’ snippets” yielded an entire listing of ‘Regular Expression Recipes’ at GitHub, a book titled “Regular Expression Recipes for Windows Developers …”, and a site for “Free Online Regular Expression Tester” among others … Enjoy!!
scrive
After searching for additional useful RegEx ‘recipes’ (following johnnyalpha’s original RegEx post) for those of us familiar with the old-style ‘LexisNexis’ style search, I’ve located the following RegEx search* that will locate two words in your Scrivener document(s) that are within X words of each other.
For example, if you want to locate (and highlight) all the occurrences of the two words ‘placeholders’ and ‘manuscript’ in Scrivener document(s) that occur within 5 words of each other, the RegEx code to use in a RegEx search that is available via the Scrivener Binder would be:
This can be a powerful tool for writers looking for words that may not appear immediately before or after each other in their documents, but together have some significance.
Here’s a nifty article describing the steps to use RegEx codes for those unfamiliar with them. It also gives a few example codes and other resources on using them.
Lancy McCall’s website lists a number of excellent RegEx expressions (as well as several excellent writing suggestions). In her section entitled ‘How Does It Work?’ Lancy presents an effective, step-by-step explanation (including screenshots) on how to implement RegEx expressions as a tool with Scrivener. She follows that up with her discussion on ‘Using RegEx While Editing’ that demonstrates how writers can use RegEx expressions to streamline their writing .
Lancy’s list made me wonder if L&L might consider creating a list of useful RegEx expressions, much like the ‘List of All Placeholders’, and make the list available as a distinct item on the Scrivener Help menu, possibly as a ‘List of Useful RegEx expressions’ ?
I just used \b([A-Z]+)\s+\1\b to find double words in a 100k print adaptation I’m working on in Scrivener. Worked like a charm! Not only that, but RegEx also works in Affinity Publisher to find any number of carry-overs from Word docs.
Lancy’s article (linked above in KruiserChicks’s post) has a nice list of more searches.