微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Google Docs 脚本,返回指定文本中间的文本值

如何解决Google Docs 脚本,返回指定文本中间的文本值

[当前结果][1] [1]:https://i.stack.imgur.com/O8AGa.png

  • 问题是它们都适用于同一行
  • 我想从同一行中单独获取
  1. 规则

    随机文本◁

    → 仅更改 ▶ 和 ◁ 之间的

  2. 当前使用的脚本

 
var body = DocumentApp.getActiveDocument().getBody();
 var foundElement = body.findText('▶([^\S]+)◁');
 
while (foundElement != null) {
   // Get the text object from the element
   var foundText = foundElement.getElement().asText();
 
   // Where in the element is the found text?
   var start = foundElement.getStartOffset();
   var end = foundElement.getEndOffsetInclusive();
 
   // Set Bold
   foundText.setBold(start,end,true);
   // Change the Foreground color
   foundText.setForegroundColor(start,"#ff326d");
 
   // Find the next match
   foundElement = body.findText('▶([^\S]+)◁',foundElement);
}


解决方法

不完全支持某些正则表达式

根据 documentation 2021/05/31 15:21:45 warn can't create table 'Data.Calls': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.Fcst_1': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.Fcst_3': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.GAInfo': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.HistoryLogs': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.Info': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.Info1': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.Info15': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.Info548': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.Info60': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.InfoAXPNew': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.InfoAXPOld': <nil>,will try again 2021/05/31 15:21:45 warn can't create table 'Data.InfoPageView': <nil>,will try again

我建议按照建议在 Google 问题跟踪器上打开功能请求here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。