如何使用 CaptureGroup "(.+?:[\/\\]+)" 反汇编字符串?

How to disassemble a string with CaptureGroup "(.+?:[\/\\]+)"?

给定的字符串:

dec:/file1.texdec:/file2.srcdec:/file3.ltx\ndec:/file4.dtxdec:/file5.insdec:/file6.src

包含串联的文件路径。

(卷名的长度(这里是:dec)是可变的,注意字符串中的换行符。)

使用 RegExp (.+?:[\/\]+)(没有 g 和 m 选项)我得到 CaptureGroup \1 dec:/.

(如果卷名称仅为 c,则 CaptureGroup 包含 c:/。路径包含 \ 而不是 /,CaptureGroup 还包含 dec:\c:\.)

如何匹配子串:

dec:/file1.tex
dec:/file2.src
dec:/file3.ltx
dec:/file4.dtx
dec:/file5.ins
dec:/file6.src

与此 CaptureGroup (.+?:[\/\]+)?

我准备了以下内容 DEMO

这就是你想要的吗?(.+?:[\/\]+)(?:(?!).)*

This is a demo on regex101.