Scripting 谷歌文档脚本,在指定文本的中间返回文本值

Scripting 谷歌文档脚本,在指定文本的中间返回文本值,scripting,expression,documentation,google-docs,Scripting,Expression,Documentation,Google Docs,[最新结果][1] [1]: https://i.stack.imgur.com/O8AGa.png 问题是它们都适用于同一行 我想从同一行中分别获取值 统治 ▶随机文本◁ → 仅在之间更改值▶ 及◁ 当前正在使用的脚本 有些正则表达式不完全受支持 根据的说法,JavaScript正则表达式功能的一个子集不完全受支持,例如捕获组和模式修饰符。 我建议按建议在Google Issue Tracker上打开一个功能请求('▶([^\S]+)◁') -> ('▶([^\S]+?)◁')

[最新结果][1] [1]: https://i.stack.imgur.com/O8AGa.png

  • 问题是它们都适用于同一行
  • 我想从同一行中分别获取值
  • 统治

    ▶随机文本◁

    → 仅在之间更改值▶ 及◁

  • 当前正在使用的脚本

  • 有些正则表达式不完全受支持 根据
    的说法,JavaScript正则表达式功能的一个子集不完全受支持,例如捕获组和模式修饰符。

    我建议按建议在Google Issue Tracker上打开一个功能请求

    ('▶([^\S]+)◁') -> ('▶([^\S]+?)◁') '?' 通过添加已完成的处理成功:)
     
    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, end, "#ff326d");
     
       // Find the next match
       foundElement = body.findText('▶([^\S]+)◁', foundElement);
    }