regex searches tips for writing novels

Tips for Writing Novels — Use RegEx

I don’t often offer tips for writing novels on here mainly because I’ve only written eight or so and only published a few, but I want to talk about RegEx.

As you guys know, I use Scrivener. I use it predominately because I’m a disordered mess of a man who is kept on the rails of productivity through raw discipline and the human equivalent of gutter bumpers. Many of those are friends, family, religious systems, and a long history of experimentation that left me going, “Nope. Never that again.” Scrivener is one of those bumper rails. It’s a long form document editor that allows for aggressive searching, reorganizing chapters, character searches, backstory, research, note cards, and — ultimately — an easy way to integrate chapters. Without Scrivener, there are no callback jokes or moments of foreshadowing in Bell Hammers. Consider that.

You can use RegEx in both Scrivener and Word. And here’s where it turns into several tips for writing novels:

RegEx is a search function typically used in coding. However, when applied judiciously it can help you tremendously with revision. Here’s how this works. The first line will give you an idea of what you’re searching for and the sub-bullet point will show you the code to type in the search bar.

Consider, for instance, if you wanted to search for a paragraph with more than 7 words in it? Why would you want to do this?

Well I did an analysis of Patrick Rothfuss’s The Name of the Wind. Do you know what his average sentence length is? And it’s a standard deviation of 6, mostly skewed towards the shorter.

On average he uses *checks notes* 4-letter words.

I’m teasing, of course. His prose is immaculate for the style he’s chosen.

So if you wanted to skew towards a style like that, here’s the sort of RegEx you’d need to move towards:

  • More than 7 sentences in a paragraph (change the 7 to change the length)
    • (?:[^\n.!?]*[.!?]){7,}
  • Words longer than 9 characters (change the 9 to change the length)
    • \w{9,}
  • A sentence with more than 10 words (change the 11 to find sentences with 11 or more words in them)
    • (?:\b\w+\b[\s,]*){11,}
  • A sentence with 3 or more of these transition words, which may indicate a run-on sentence (assuming that’s not the style you want)
    • [^.!?]*(?:\b(?:accordingly|and|but|or|additionally|furthermore|afterward|albeit|although|besides|consequently|conversely|even\s+so|even\s+though|further|furthermore|hence|henceforth|however|in\s+addition|indeed|lest|likewise|meanwhile|moreover|nevertheless|nonetheless|notwithstanding|otherwise|rather|still|thereby|therefore|thereupon|thus|whereas|yet)\b[^.!?]*)+[.!?]
  • Find all caps words to use them sparingly:
    • \b[A-Z]+\b
  • In my current manuscript, I had one character named Miah — as in Jeremiah’s nickname — and one character named Mia — as in both Maria and Italian for “mine”. Halfway through I was CONFUSING MYSELF, even though I knew not to do this. Not to even start a character name with the same letter until I’d used up the alphabet and, where possible, seldom in the same scene. Harry. Hermione. Hagrid. Yeah we get it, but it can grow tiresome. So to search for “Mia” and not include “Miah” I needed to find the word “Mia” followed by a space or any punctuation. A simple find and replace would break the manuscript. Consider too words like amia, bulimia, Bohemia, leukemia, and hypomagnesaemia. Okay, magnesium deficiency didn’t come up, but still. Here’s the RegEx I needed:
    • Mia(?:\s|\p{P})
  • Find words that are repeated within a page (250 words) that aren’t one of the most common 15 words. It’ll make it easy to find where you repeated words:
    • (?i)\b(?!the\b|be\b|to\b|of\b|and\b|a\b|in\b|that\b|have\b|i\b|it\b|for\b|not\b|on\b|with\b)([a-z]+)\b(?=(?:\W+[a-z]+){0,249}\W+\1\b)
READ NEXT:  Stop Plastic Bottles Graffiti

Any of the first three you can edit by changing the number variable. 

Do you have any RegEx searches to share?

What about tips for writing novels?


Be sure to share and comment. And subscribe.

Comment early, comment often, keep it civil:

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Please comment & share with friends how you prefer to share:

Follow The Showbear Family Circus on WordPress.com

Thanks for reading the Showbear Family Circus.
  1. Like this, very noir. Can smell the stale smoke and caustic aroma of burnt coffee. That mewling grunt of a…

  2. Years ago, (Egad, 50 years ago!) I was attending Cal (Berkeley) I happened to be downtown, just coming out of…

Copyright © 2010— 2023 Lancelot Schaubert.
All Rights Reserved.
If we catch you using any of the substance of this site to train any form of artificial intelligence, we will prosecute
to the fullest extent permitted by any law.

Human children and adults always welcome
to learn bountifully and in joy.