Compile Replacement Issue - regex

OSX: 10.8.5
Scrivener: 2.5 (25239)

Compiling into a MOBI (if that matters) with replacements. The source text is (note the italics):

I have the following replacement defined:

My expected output is:

But the italic formatting is being stripped out, so I get this instead:


Since regex is a plain-text engine, if components of the text within the replaced range have special formatting it would be expected to lose it. It should work when the matched range is within a formatting range, even if it is the entire range. Thus the following would end up with “good men to come” italicised:

That’s a shame, and pretty much makes this a useless feature.

No it doesn’t, it just makes it less useful for your particular use-case. :slight_smile: This is something you’d need to take up with Apple, though - their implementation of NSRegularExpression only works on plain text.

Instead of this:

Replace: <\{<(.*?)>\}> With: $1 Regex: yes

Do this:

Replace: <\{<|>\}> With: Regex: yes

That will strip away the <{< and >}> brackets, leaving the text between them alone.

Thanks, RDG, that works great!