实现epub中链接脚注加1的操作
操作视图:
代码:
namespace epub统一修改数字加1操作
{
public partial class epub统一修改数字加1 : Form
{
public epub统一修改数字加1 ()
{
InitializeComponent();
richTextBox1.Text = "文件需位于d盘下的11.txt文件,请稍候!";
}
修改/
privatevoid button2_Click(objectsender, EventArgs e)
{
try
{
strings = richTextBox1.Text;
Regexreg = new Regex("<a\\s+class=\"footnote-link\"\\s+href=\"#footnote-(?<f1>\\d+)-(?<f2>\\d+)\"\\s+id=\"footnote-\\d+\\-\\d+\\-backlink\">\\d+</a>",RegexOptions.IgnoreCase);
MatchCollectionmac = reg.Matches(s);
foreach(Match m inmac)
{
stringf1 = m.Groups["f1"].Value;
stringf2 = m.Groups["f2"].Value;
int_f1 = int.Parse(f1) + 1;
int_f2 = int.Parse(f2) + 1;
s = s.Replace("href=\"#footnote-" + f1 + "-" + f2 + "\"id=\"footnote-" + f1 + "-"+ f2 + "-backlink\">" + f2+ "</a>", "href=\"#footnote-" + _f1 + "-" + _f2 + "\"id=\"footnote-" + _f1 + "-"+ _f2 + "-backlink\">" +_f2 + "</a>");
}
richTextBox1.Text = s;
MessageBox.Show("修改成功");
}
catch(Exception eee) {
MessageBox.Show("修改失败");
}
}
打开文件/
privatevoid button1_Click(objectsender, EventArgs e)
{
try
{
richTextBox1.LoadFile(@"d:\11.txt", RichTextBoxStreamType.PlainText);
}
catch(Exception ee)
{
MessageBox.Show("找不到文件");
}
}
保存按钮//
privatevoid button3_Click(objectsender, EventArgs e)
{
try
{
richTextBox1.SaveFile(@"d:\11.txt", RichTextBoxStreamType.PlainText);
MessageBox.Show("保存成功");
}
catch(Exception eeee)
{
MessageBox.Show("保存失败");
}
}
}
}