Google Apps脚本findtext searchpattern格式? [英] Google Apps Script findtext searchpattern format?

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

问题描述

我正在尝试传递

findText("/a/");

findText(/a/);

,但找不到任何东西.如果我只输入像这样的文字

but it does not find anything. If I pass in only the text that works like this

findText("a");

如何在其中传递正则表达式字符串?

How to pass regex strings in there?

推荐答案

使用String.search()方法.

Use the String.search() method.

 function test(){
    var testString = "1212a1212";
    var results = testString.search(/a/);
    Logger.log(results);  //results = 4;
  }

这篇关于Google Apps脚本findtext searchpattern格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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