0
我一直在努力處理一段時間以來的腳本。問題是,當我像文本運行腳本:Google Apps腳本自動大寫
Hi. apples are amazing.
我想要只在蘋果的一個資本,而是文本出來爲:
Hi. Apples Are Amazing.
下面是代碼:
function caps()
{
var body = DocumentApp.getActiveDocument().getBody();
var text = body.editAsText()
var caps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var lower = "abcdefghijklmnopqrstuvwxyx";
//while (() != null) {
//var search = text.findText('. a')
//var start = replace - 1
//text.deleteText(start, replace)
//text.insertText(start, " A")//}
for(var i=0; i<caps.length; i++)
{
var nextCaps = caps.charAt(i);
var nextLower = lower.charAt(i);
while (text.findText('. ' + nextLower) != null)
{
Logger.log(nextLower)
Logger.log(nextCaps)
var search = text.findText('. ' + nextLower)
var replace = search.getEndOffsetInclusive()
var start = replace - 1
text.deleteText(start, replace)
text.insertText(start, " " + nextCaps)
}
//var nextChar = caps.charAt(i);
//Logger.log(nextLower)
}
}
基本上,代碼查找,並用 「A」。(同樣用b,c,d和等)替換它 「一個」。如果有人能幫助我,這將非常感激。
謝謝!我也喜歡這樣做的簡短的代碼量!如果我能評價它,我會評價它5分之10! – 2014-10-05 05:26:10