替换文本框中的文本 [英] Replacing text in Textbox

查看:86
本文介绍了替换文本框中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在发布部门的网站上工作,我在PDF上工作,其中包含许多与税收和会计相关的内容.通常,我收到的每个PDF都会有如下所示的索引.

12230会计师变更
12240会计年度变更
12250审核员问题

INDEX中的该文本将再次在内容中重复,作为标题,如下所示.

12230会计师变更
(最新更新:2009年6月30日)
12230.1除非同一位会计师在最近的财务报表中报告了
既是注册人又是会计收购人,总是反向收购


我将PDF转换为文本,然后将INDEX部分分开,将其放置在textbox1中,其余内容放置在textbox2中.

当粘贴到Textbox1中时,我的INDEX如下所示:

< p> 12230会计变更</p>
< p> 12240会计年度的变化</p>
< p> 12250审核员问题</p>


文本框中的内容将如下所示:


12230会计师变更
(最新更新:2009年6月30日)
12230.1除非同一位会计师在最近的财务报表中报告了

12240会计年度变更
12240.1因反向收购而提交的8-K表格应在
下披露 表格8-K中第5.03项,从会计年度起对会计年度的任何预期变更
收购前注册人使用的年结.

12250审计师问题
(最新更新:2009年6月30日)
12250.1与公开壳牌公司进行反向注资


因此,只要INDEX(textbox1)中的文本在内容(textbox2 粗体)中重复,我就需要添加标题级别(前缀和后缀标签)

例如:< hd1><名称> 12230单击按钮即可更改会计师</name>" .

我实际上正在寻找的是查找和替换选项.在textbox1( Index )的每一行中找到内容,然后将该文本替换为textbox2( Content )中上面建议的标签.

这里的挑战是从textbox1中找到单独的行,并替换textbox2中位于文档中间某处的相同内容.

Hi,

I work for a website in publishing dept and i work on PDF''s with lot of content related to tax and accounting. Usually every PDF i receive will have a INDEX like below.

12230 Change in Accountants
12240 Change in Fiscal Year
12250 Auditor Issues

This text in INDEX will again repeat in the content as heading for a paragaraph like below.

12230 Change in Accountants
(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


I will convert the PDF in to text and Then i will seperate the INDEX part and place it in textbox1 and rest of the content in textbox2.

When pasted in Textbox1 my INDEX will look like below:

<p>12230 Change in Accountants</p>
<p>12240 Change in Fiscal Year</p>
<p>12250 Auditor Issues</p>


And content in Textbox will look like below:


12230 Change in Accountants
(Last updated: 6/30/2009)
12230.1 Unless the same accountant reported on the most recent financial statements

12240 Change in Fiscal Year
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.

12250 Auditor Issues
(Last updated: 6/30/2009)
12250.1 Reverse Recapitalization with a Public Shell Company


So whenever the text in INDEX(textbox1) is repeating in the content(textbox2 bold content) i need to add the heading levels(Prefix and suffix Tags)

Eg: "< hd1 >< name >12230 Change in Accountants< /name >" with a button click.

What i am actually looking for is a find and replace option. Find the content in textbox1(Index) individual line and replace that text with the tags suggested above in textbox2(Content).

The challenge here is find the individual line from textbox1 and replace that same content in textbox2 which is placed somewhere in the middle of the document.

推荐答案

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

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


这篇关于替换文本框中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆