Flutter 分割字符串并保持分隔符

Cha*_*ige 5 regex dart flutter

在颤振中使用正则表达式分割时如何保留分隔符?

文本:"this is {{A}} sample {{text}} ..."

我想要的是:["this is", "{{A}}", "sample", "{{text}}", "..."]

我使用了以下正则表达式,

"this is {{A}} sample {{text}} ...".split(RegExp("{{(.*?)}}"))

并得到,["this is ", " sample ", " ..."]

Cha*_*ige 1

这对我有用。

(?={{)|(?<=}})
Run Code Online (Sandbox Code Playgroud)

演示