Skip to content

Instantly share code, notes, and snippets.

@tanaikech
Created March 11, 2023 05:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanaikech/ec156204f3a2d96873dce5f6ba4674d6 to your computer and use it in GitHub Desktop.
Save tanaikech/ec156204f3a2d96873dce5f6ba4674d6 to your computer and use it in GitHub Desktop.
Removing Quote Prefix of Cell value using Google Apps Script (Single Quote)

Removing Quote Prefix of Cell value using Google Apps Script (Single Quote)

In Google Spreadsheet, when a single quote is added to the top letter of the cell value, the cell is used as the text value. About detecting this, I have already reported in this post in my blog. In this post, I would like to introduce a sample script for removing the single quote at the top character of the cell value.

Sample script:

function sample() {
  const sheetName = "Sheet1"; // Please set your sheet name.

  const range = SpreadsheetApp.getActiveSpreadsheet()
    .getSheetByName(sheetName)
    .getDataRange();
  range
    .createTextFinder("^'{1,}")
    .useRegularExpression(true)
    .replaceAllWith("");
  range.setValues(range.getValues());
}
  • In this script, for example, '001, '''001, 'abc, and '''abc are converted to 1, 1, abc, and abc, respectively.

Reference:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment