实现epub中链接脚注加1的操作

实现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("保存失败");

            }

        }

        }

    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值