LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Sunday, February 11, 2018

先頭の文字を正規表現で置換する


正規表現で先頭の文字を置換するコードの例です

正規表現


/^./
^先頭の
.1文字



コード.gs
function replace_first_letter(){
  var str = "abc"; 
  var result = str.replace(/^./, "x");
  Logger.log(result);
}
意訳
この機能がやること
文字列
先頭の1文字をxに変えて 
結果をログに出す




実行結果



Latest post

Creating a template copier app in Google Apps Script

Introduction This article will show you a template copier application in Google Apps Script.  This application will automatically copy a t...