日期:2014-05-18 浏览次数:20837 次
string file_name = "abc.txt"; ArrayList old_array = new ArrayList() { "abc/01", "sss/02" }; ArrayList new_array = new ArrayList() { "cba/00A","ttt/00B" }; string file_part = Regex.Match(file_name, @"[^.]+(?=\.)").Value; string new_file_name = string.Empty; for (int i = 0; i < old_array.Count; i++) { Regex reg = new Regex(@"[^/]+(?=/)"); string check_str_old = reg.Match(old_array[i].ToString()).Value; if (check_str_old.Equals(file_part)) { new_file_name = reg.Match(new_array[i].ToString()).Value; break; } else continue; } //new_file_name : "cba"