2011-10-21 251 views
1

我有以下行:正則表達式字符串替換。

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

任何特定的語言? – aioobe

+1

它是否總是'qqq'或三次相同的字母或別的東西? – lkuty

回答

0

我認爲應該工作:

.*\\(?:qqq)?(?<A>.*)\\(?:qqq)?(?<B>.*)