1

A given string:

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

contains concatenated file paths.

(The length of the volume name (here: dec) is variable. Pay attention to the line break in the string.)

With the RegExp (.+?:[\/\\]+) (without g and without m options) I get the CaptureGroup \1 dec:/.

(If the volume name is only c the CaptureGroup contains c:/. With path containing \ instead of / the CaptureGroup also contains dec:\ or c:\.)

How can I match the substrings:

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

with this CaptureGroup (.+?:[\/\\]+)?

I have prepared the following DEMO

CarpeDiemKopi
  • 316
  • 3
  • 13

1 Answers1

1

This is what you want it ?(.+?:[\/\\]+)(?:(?!\1).)*

This is a demo on regex101.

Oliver Hao
  • 715
  • 3
  • 5