且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换文本框中的文本

更新时间:2022-04-02 22:39:48

不要简单地查找并替换工作,或者在查找和替换时遇到任何其他问题.

Wont a simple find and replace work or you are having any other issues with find and replace.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Test
{
    class RegexProcessing
    {

        public void process()
        {
            string value = "12230 Change in Accountants\r\n" +
                           "12240 Change in Fiscal Year\r\n" +
                           "12250 Auditor Issues";
            string modifiedValue = "12230 Change in Accountants\r\n" +
            "(Last updated: 6/30/2009)" +
            "12230.1 Unless the same accountant reported on the most recent financial statements of\r\n" +
            "both the registrant and the accounting acquirer, a reverse acquisition always\r\n" +
            "12240 Change in Fiscal Year\r\n" +
            "12240.1 A Form 8-K filed in connection with a reverse acquisition should disclose under\r\n" +
            "Item 5.03 of the Form 8-K any intended change in fiscal year from the fiscal\r\n" +
            "year end used by the registrant prior to the acquisition\r\n" +
                "12250 Auditor Issues\r\n" +
            "(Last updated: 6/30/2009)\r\n" +
            "12250.1 Reverse Recapitalization with a Public Shell Company\r\n";

            string[] lines = System.Text.RegularExpressions.Regex.Split(value, "\r\n");

            foreach (string line in lines)
            {
                modifiedValue = modifiedValue.Replace(line, "<hd1><name>" + line + "</hd1></name> ");
            }
            Console.WriteLine(modifiedValue);
        }
    }
}



输出:



Output :

<hd1><name>12230 Change in Accountants</hd1></name>
(Last updated: 6/30/2009)12230.1 Unless the same accountant reported on the most recent financial statements of
both the registrant and the accounting acquirer, a reverse acquisition always
<hd1><name>12240 Change in Fiscal Year</hd1></name>
12240.1 A Form 8-K filed in connection with a reverse acquisition should disclose under
Item 5.03 of the Form 8-K any intended change in fiscal year from the fiscal
year end used by the registrant prior to the acquisition
<hd1><name>12250 Auditor Issues</hd1></name>
(Last updated: 6/30/2009)
12250.1 Reverse Recapitalization with a Public Shell Company