正则表达式的字符串替换方法
我有以下几行:
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从行。 我一直在试图与调节,并有部分的解决方案:
.*\\(?<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}应固定
1.我认为,应该工作:
.*\\(?:qqq)?(?<a>.*)\\(?:qqq)?(?<b>.*)
下一篇: python3判断IP地址的方法