A special type of replacement during compiling

Inside the inspector notes of a document, I have a vast number of ‘aides-mémoire’ (short notes regarding things checked, things to check, things to remember, etc.), which are put between ## … ##.

But now I want to send this document to a colleague, but without these personal notes, which are no part of the text as such and are for my eyes only. So they have to be stripped out during compiling.

In the compile window, there is a replacements window. But what exactly do I have to fill in there in order to erase from the compiled text all these ## … ## and everything that’s between them?

Are inspector notes even compiled?

In the body text, this should work:

(1) Replace: ##.+?##
(3) Tick the RegEx box

When compiled, Scrivener should remove all the instances of ##WHATEVER TEXT YOU HAVE WRITTEN##.

Hope it works. Tried it on a test file here and it worked perfectly.

Credit to roberdguthrie for this post:

You can just not include the notes (you’re talking about the yellow “Document Notes” pane in the inspector, right?) by un-ticking the “Notes” checkbox in the Formatting pane of compile.

If you’re talking about inspector comments (little sticky notes) in the inspector, then you can go to Footnotes/Comments in the compile window to strip those out during compile.

I had a hunch you’d have a better answer. :smiley:

To the OP, if you do want to compile the notes (document and/or little sticky) but omit the ##comments## that you’ve made, the method I mentioned above does remove the text selectively from the notes, as well as from the body text.

Ha! It’s unclear which of us gave the appropriate response. I can’t tell for sure if by “inspector notes” the OP means Document Notes or Inspector Comments, and whether there are notes NOT ##delimited## like that that need to be compiled. We make a good team, like the Wonder Twins. Only without the purple body suits.

Unless… are you wearing a purple spandex body suit too? :blush:

Are you trying to make enemies? I have enough fatal images in my head thanks to vic-k. I don’t need you sponsoring them as well…

Is it a bad thing to admit that I had to look up the Wonder Twins on the net? :open_mouth:

Me in spandex: a criminal offence.

The response I was looking for was given by Briar: perfect, works like a charm indeed! But I’m grateful to both Briar and Robert: thanks to both of you!

But … where can such information about the syntax of replacement formulas be found?


Essentially, I just copied out Robert’s idea from another thread, so all the credit is due to him.

You have to be a member of Formula Club, but the first rule of Formula Club is that you’re not allowed… :smiley:

Serious answer: I don’t know. I think that Robert is the guru you need to get a reply from.

Replacement syntax can be found in 24.18.1 Advanced Replacement Usage of the user manual PDF (pg. 400). Do note that the token method described here, where you can search for something like ##$@## to capture everything between double-hashes, currently has a flaw in that you can’t take that and replace it with nothing (or indeed, anything that doesn’t contain the $@ token in the With field). So for now the RegEx example above is the way to go. Generally speaking the simple delimiter approach will be more efficient against CPU cycles than running the entire Regular Expression engine—more an issue for large compile outputs, where tweaking for performance can mean the difference between a five minute compile and a 45 second compile.

As noted however, there are some great ways to jot down notes to yourself without having to resort to tricks like these. Inline annotations and linked comments are a great way to jot down ideas and to-do items without them showing up when you compile.

As for Regular Expression syntax, well there have been 500+ page technical manuals written on that particular topic. :slight_smile: Even providing a tutorial would be a gratuitous use of space in the Scrivener user manual. Here is a fantastic tutorial on basic regex that will take you into intermediate and advanced usage if you so choose.

How would you know what’s in your head? :laughing:

Everything I know about Regular Expressions I learned from the first two chapters of shop.oreilly.com/product/9780596528126.do, a few PERL programming books, and ahem regular google searches for “regex for matching ________” or “regex for swapping two things” and the like…

Regular expressions are a dark art with a few limitations to their text matching and manipulative power, but you only really need a handful of tricks to eliminate passages from your text. If you want an in-depth answer to “what does ##.+?## do,” you can just search for “regex ________ operator” where you fill in the blank with the name of the text symbol (google doesn’t do well with punctuation symbols), or just ask. Either Ioa or I will break it down for you, symbol-by-symbol. You’ll learn more from Ioa’s link however. It’s a good resource I highly recommend if you really want to learn regular expressions.

It’s contents are all over the place. All I have to do is look around and see what I was thinking!