在netsuite suitescript 1.0中,我想检查一个字符串是否有一组关键字。在 javascript 中有一个函数称为 .includes("Set_of_keywords_to_be_searched"); 我在 netsuite 中尝试了 .includes,但它给出了错误。
例如:
var str = "Hello world, welcome to the javascript.";
var n = str.includes("world"); // this will return true
var n = str.includes("Apple"); // this will return false
我想在 netsuite 中有类似的功能。
最佳答案
使用 RegExp
和 test
方法。参见 MDN Reference
看起来像
var pattern = /world/;
var n = pattern.test(str);
String#includes
仅在 ES2015 中添加。 NetSuite 运行的是 Rhino 1.7 JS 引擎,不支持任何 ES2015 或更高版本的 JS 特性。
关于netsuite - 在netsuite中找到一个字符串,打印出来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40975611/