如何使用 CaptureGroup“(.+?:[\/\\]+)"反汇编字符串? [英] How to disassemble a string with CaptureGroup "(.+?:[\/\\]+)"?

查看:37
本文介绍了如何使用 CaptureGroup“(.+?:[\/\\]+)"反汇编字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定的字符串:

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

包含连接的文件路径.

contains concatenated file paths.

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

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

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

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

(如果卷名只有 c,则 CaptureGroup 包含 c:/.路径包含 \ 而不是 / CaptureGroup 还包含 dec:\c:\.)

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

如何匹配子字符串:

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

使用这个 CaptureGroup (.+?:[\/\\]+)?

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

我准备了以下内容演示

I have prepared the following DEMO

推荐答案

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

这是一个关于 regex101 的演示.

这篇关于如何使用 CaptureGroup“(.+?:[\/\\]+)"反汇编字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆