Google Dart有类似regex.exec()的东西吗?

时间:2017-01-18 19:03:02

标签: dart

我阅读了文档(https://api.dartlang.org/stable/1.21.1/dart-core/RegExp-class.html),但找不到我在找。要么我不理解它,要么忽略了一些东西。

我想在google dart中复制以下内容:

var regex = /foo_(\d+)/g,
    str = "text foo_123 more text foo_456 foo_789 end text",
    match = null;

while (match = regex.exec(str)) {
    console.log(match); // matched capture groups
    console.log(match.index); // index of where match starts in string
    console.log(regex.lastIndex); // index of where match ends in string
}

我还创建了一个jsfiddle:https://jsfiddle.net/h3z88udz/

dart是否有类似regex exec()的东西?

1 个答案:

答案 0 :(得分:4)

ga('create', 'UA-XXXX-Y', 'auto'); // Send the custom dimension value with a pageview hit. ga('send', 'pageview'); // Load and set value for custom dimension at index 1 from an API ga('set', 'dimension1', 'Level 1'); ---> Send the dimension to Google without double counting the pages in GA 看起来像你想要的那样。

RegExp.allMatches

https://dartpad.dartlang.org/dd1c136fa49ada4f2ad4ffc0659aab51