Google脚本查看文本是否包含值 [英] Google Script to see if text contains a value

查看:114
本文介绍了Google脚本查看文本是否包含值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google表单,当用户提交时,它会触发我的函数运行,它将创建他们作为Google Doc提交的内容的摘要。我知道它可以自动发送电子邮件,但我需要它的格式,以便我的用户稍后可以编辑它。

表单上有一些复选框 - 但getResponse()只填充了选中的项目,我需要它显示所有可能的选项。然后我会以某种方式指出检查的内容。



我无法找到一种方法来查看文本是否包含值。
像使用String的Java一样,我可以执行 .contains(9th) .indexOf(9th)> ; = 0 然后我会知道String包含9。我怎样才能用谷歌脚本来做到这一点?看过所有的文档,我觉得它一定是最容易的事情。

  var grade = itemResponse.getResponse(); 

需要查看等级是否包含9。



感谢!

解决方案

Google Apps脚本是JavaScript,您可以使用所有的字符串方法...

  var grade = itemResponse.getResponse(); 
if(grade.indexOf(9th)> -1){do something}



<例如,您可以在许多网站上找到doc,例如这一

I have a google form that when the user submits it will trigger my function to run which is creating a summary of what they submitted as a Google Doc. I know it can automatically send an email but I need it formatted in a way that my user can edit it later.

There are some check boxes on the form -- but the getResponse() is only populated with the items checked and I need it to show all possible choices. Then I will indicate somehow what was checked.

I can't find a way to see if a text contains a value. Like in Java with a String, I could do either .contains("9th") or .indexOf("9th") >=0 and then I would know that the String contains 9th. How can I do this with google scripts? Looked all through documentation and I feel like it must be the easiest thing ever.

var grade = itemResponse.getResponse();

Need to see if grade contains 9th.

Thanks!

解决方案

Google Apps Script is javascript, you can use all the string methods...

var grade = itemResponse.getResponse();
if(grade.indexOf("9th")>-1){do something }

You can find doc on many sites, this one for example.

这篇关于Google脚本查看文本是否包含值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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