组合字符串 [英] Combining Strings

查看:77
本文介绍了组合字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Google Apps脚本的新手,正在尝试合并一系列字符串.我有两个字符串需要在输入的单元格之前和之后移动.

I am new to Google Apps Script and am trying to combine a series of strings. I have two strings that need to go before and after an inputted cell.

if B4 = "string2"下一行的结果应为"string1 string2 string3". "string1 " + "B4" + " string3"

if B4 = "string2" the result of the following line should be "string1 string2 string3" . "string1 " + "B4" + " string3"

String1和string3将始终相同,因此我可以将它们分别设置为变量,但是我不知道如何将它们连接在一起.需要将它们合并并输出到表格中的单元格中.

String1 and string3 will always be the same so I can set them each to a variable, but I don't know how to concatenate them together. They need to be combined and outputted to a cell in Sheets.

任何帮助将不胜感激.

Any help would be greatly appreciated.

推荐答案

字符串很容易在JavaScript中组装,只需使用+

Strings are very easy to assemble in JavaScript, simply add them using +

根据您的示例:

"string1"+" "+string2+" "+"string3"

或者,您可以使用 .concat方法完全一样.

Alternatively you can use the .concat method that does exactly the same.

这篇关于组合字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆