我需要一种方法,使用Google Apps脚本将字符串的一部分替换为另一个字符串.我测试了以下内容并且它有效:
function test(){
var value = 'https://plus.google.com/117520727894266469000';
var googleimageURL = googlePlus(value);
Logger.log('Returned Result: ' + googleimageURL);
}
function googlePlus(value){
var apiKey = ScriptProperties.getProperty('apiKey');
var re = 'http://'
var theURL = value;
Logger.log('Google+ is called: ' + value);
var replacingItem = 'https://';
var theURL = theURL.replace(re, replacingItem);
Logger.log('Google+ Values 2: ' + value + ' : ' + theURL + ' after ' + replacingItem);
return imageURL;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我嵌入以下代码时,它无法正常工作.任何的想法?
//If a Google+ column was not specified,put a flag.
if (googleColumn …Run Code Online (Sandbox Code Playgroud)