问题
I have asked on how to delete between values between the tags and i got solution of which i had to modify to meet my needs, but now the problem is it doesn't delete the values between the tags and i debug to see the error but no error was found. when i check the file that is been created i can still see the values inside the tags. please help me
under new button which copies the file
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);
}
Function
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;
}
来源:https://stackoverflow.com/questions/28451833/deleting-between-the-tags-it-is-not-deleting