0
我有下面的C#代碼來使用正則表達式比較文件名。使用正則表達式匹配文件名
private string PPMFileName = "p_p_m";
private string FilePattern = PPMFileName + @"(.*)\.csv"; //File gets appended with date
private Regex regex = new Regex(FilePattern)
if(regex.IsMatch(file.Name))
//do my stuff
它返回甚至是文件名p_p_m_er_bo_20140324.csv,在那裏,我希望它只是返回文件名p_p_m_20140324.csv真(日期會不斷變化)真。
真棒。沒有意識到Regex.Escape。 – Cannon