Trying to change single quotes to double quotes.

199 views
Skip to first unread message

MuppetGate

unread,
Nov 30, 2011, 8:43:55 AM11/30/11
to TextSoap
Hi there.

I have a whole project full of Scrivener documents that I need to run
through a simple(ish) conversion. I want to change the single quotes
into double quotes.

Best I could come up with was a two stage process:

Convert the single quotes to doubles (which will also convert the
apostrophes in !'m and didn't etc.)

Next run a regex over it:
Find ([^ \n)"([^ \n])
Replace with \1'\2

The problem is that the replace for the apostrophes isn't working.
Rather than doing the group replacement, it's just replacing the
everything with \1'\2. I thought substitution was supported, so I'm
not sure what I'm doing wrong.

Any help would be very much appreciated.

Thanks.

Mark Munz

unread,
Nov 30, 2011, 10:52:18 AM11/30/11
to text...@googlegroups.com
First, substitution is supported, but the replacement syntax in ICU is
$1 $2, not \1 \2 -- see Help > Regex Reference in TextSoap menu for
more complete details of the ICU syntax.

Second, you could do something like

Find: (\w)(')(\w)
Replace: $1’$3 { that's a curly apostrophe }

Find: '
Replace: "

Find: ’ { that's a curly apostrophe }
Replace: '

Effectively replacing any single quote surrounded by word letters on
both sides to a curly apostrophe, covert your single quotes to double
quotes, finally find the curly apostrophe and convert it back to a
straight apostrophe.

This does make the assumption that you would not embedded quotes
within a word. That would be considered the most common situation as
most people would not'quote'text like this. But this will fail if you
use things like 'cause hangin' etc. Because these are really
exceptions, it's easier to special case them. Use the bulk find and
replace action to find those words after the conversion in their new
form: "cause hangin" or replace them beforehand with the standard
words.

> --
> You received this message because you are subscribed to the Google Groups "TextSoap" group.
> To post to this group, send email to text...@googlegroups.com.
> To unsubscribe from this group, send email to textsoap+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/textsoap?hl=en.
>

--
Mark Munz
unmarked software
http://www.unmarked.com/

Iridescent Words

unread,
May 10, 2024, 11:17:32 AMMay 10
to TextSoap
Hi Mark,
Does this find and replace work on Scrivener or Google docs? Is there a find replace button on Scrivener you can use instead of coding? I need to change all the quotes in my manuscript from double to single, and the online converters don't work. Any help would be appreciated. 

Regards,
Malina

Reply all
Reply to author
Forward
0 new messages