string pattern = ".+\\";
foreach (string file in files){
richTextBox2.Text += Regex.Replace(file, @pattern, String.Empty) +"\n";
}
我想要做什麼應該是一個簡單的模式匹配和替換,文件包含完整路徑,例如:d:\test\t.txt
。但每次它都會粉碎並說Illegal \ at the end of the pattern.
沒有快樂,我哪裏錯了?Regex.Replace的模式無法正常工作
葉氏,現在的工作很好,非常感謝! – Disciples
賓果!在做正則表達式時,最好使用逐字串來減少混淆。 @ 「+ \\」 – Logarr