我已经询问如何删除标签之间的值,我得到了解决方案,我必须修改以满足我的需求,但现在问题是它不删除标签之间的值,我调试看到错误但没有发现错误。当我检查已创建的文件时,我仍然可以看到标签内的值。请帮帮我
在新按钮下复制文件
XmlReadMode omode = oDataSet.ReadXml(PathSelection);
for (int i = 0; i < oDataSet.Tables[2].Rows.Count; i++)
{
string comment = oDataSet.Tables["data"].Rows[i][2].ToString();
string font = DeleteBetween(comment, "[Font]", "[/Font]");
string datestamp = DeleteBetween(comment, "[DateStamp]", "[/DateStamp]");
string commentVal = DeleteBetween(comment, "[Comment]", "[/Comment]");
string[] row = new string[]
{
oDataSet.Tables["data"].Rows[i][0].ToString(),
oDataSet.Tables["data"].Rows[i][1].ToString(),
font,
datestamp,
commentVal
};
File.Copy(txtInputfile.Text, txtInputfile.Text.Replace("string-en.resx", "string-lan.resx"));
Gridview_Output.Rows.Add(row);
}
功能
public string DeleteBetween(string STR, string FirstString, string LastString)
{
string regularExpressionPattern1 = @"(?:\" + FirstString + @")([^[]+)\[\/" + LastString;
Regex regex = new Regex(regularExpressionPattern1, RegexOptions.Singleline);
MatchCollection collection = regex.Matches(STR.ToString());
var val = string.Empty;
foreach (Match m in collection)
{
val = m.Groups[1].Value;
}
return val;
}