正则表达式字符串替换(Regular expression String replacement.)
我有以下几行:
d:\Projects\qqq\Development\qqq.MySol1.sln d:\Projects\qqq\qqqDevelopment\qqqMySol2.sln d:\Projects\qqq\Development\MyInstaller.sln d:\Projects\qqq\qqq\Development\MyInstaller.sln d:\Projects\Development\MyInstaller.sln我需要一个会导致名称捕获的正则表达式:
Line 1: Development and MySol1.sln Line 2: Development and MySol2.sln Line 3: Development and MyInstaller.sln Line 4: Development and MyInstaller.sln Line 5: Development and MyInstaller.sln所以正则表达式将从行中删除(忽略)单词qqq 。 我一直在尝试使用The Regulator,并有一个部分解决方案:
.*\\(?<A>.*)\\.{3}(?<B>.*)这导致:
Line 1: Development and .MySol1.sln Line 2: qqqDevelopment and MySol2.sln Line 3: Development and nstaller.sln Line 4: Development and nstaller.sln Line 5: Development and nstaller.sln所以.{3}应该以某种方式修复。
I have the following lines:
d:\Projects\qqq\Development\qqq.MySol1.sln d:\Projects\qqq\qqqDevelopment\qqqMySol2.sln d:\Projects\qqq\Development\MyInstaller.sln d:\Projects\qqq\qqq\Development\MyInstaller.sln d:\Projects\Development\MyInstaller.slnI need an regular expression that will result in name captures:
Line 1: Development and MySol1.sln Line 2: Development and MySol2.sln Line 3: Development and MyInstaller.sln Line 4: Development and MyInstaller.sln Line 5: Development and MyInstaller.slnSo a regex that will remove (ignore) the word qqq from the lines. I've been trying with The Regulator, and have a partial solution:
.*\\(?<A>.*)\\.{3}(?<B>.*)This results in:
Line 1: Development and .MySol1.sln Line 2: qqqDevelopment and MySol2.sln Line 3: Development and nstaller.sln Line 4: Development and nstaller.sln Line 5: Development and nstaller.slnSo the .{3} should be fixed somehow.
最满意答案
我认为应该有效:
.*\\(?:qqq)?(?<A>.*)\\(?:qqq)?(?<B>.*)I think that should work:
.*\\(?:qqq)?(?<A>.*)\\(?:qqq)?(?<B>.*)更多推荐
发布评论