Reputation: 3509
I have a problem with Smart Quotes in Google Docs that related to the apostrophe character.
For example, if I type the string Employee's Name
, it will become Employee’s Name
Notice how the apostrophes are different.
I need to find a way to replace all those ’
to '
, and all other "Smart" Quotes characters using Apps Script
It can be done by using replace function, I guess. But I don't know "what" to be replaced. Is there a list of Smart Quotes characters?
So how to solve this problem? Thanks.
Note: I know I can disable this feature by going to Tools
-> Preferences
and disable Use smart quotes
, but I can't do this way, because I'm working on an add-on
Upvotes: 1
Views: 740
Reputation: 4440
Smart quoting replaces the single apostrophe and the double quote into its "smart" (“smart”, rather) equivalents. More info about the characters used here.
If you are using Google Docs, you may want to use the replaceText(searchPattern, replacement)
function. See below an example code snippet using this function:
var body = DocumentApp.getActiveDocument().getBody();
body.replaceText("(‘|’)", "'");
body.replaceText('(“|”)', '"');
Upvotes: 2