简体   繁体   English

如何在Notepad ++中替换以特定单词开头的每一行的结尾?

[英]How to replace end of every line that starts with a specific word in Notepad++?

I have a document that looks something like this: 我有一个看起来像这样的文档:

<Objects>
    <Object>
        <Id>1</COLUMN>
        <Type>Type1</COLUMN>
        <Name>Some name</COLUMN>
    </Object>
    <Object>
        <Id>2</COLUMN>
        <Type>Type2</COLUMN>
        <Name>Some name2</COLUMN>
    </Object>
</Objects>

How can I replace all the </COLUMN> in the end of the lines so they match the type shown in the beginning of the lines using Notepad++? 如何使用Notepad ++替换行尾的所有</COLUMN> ,使其与行首显示的类型匹配? I want the result to be something like this: 我希望结果是这样的:

<Objects>
    <Object>
        <Id>1</Id>
        <Type>Type1</Type>
        <Name>Some name</Name>
    </Object>
    <Object>
        <Id>2</Id>
        <Type>Type2</Type>
        <Name>Some name2</Name>
    </Object>
</Objects>

搜索: <(\\w+)>(.*)</COLUMN>替换为: <\\1>\\2</\\1>

You can use the following to match: 您可以使用以下内容进行匹配:

(<([^>]+)>[^<]+)<\/COLUMN>

And replace with the following: 并替换为以下内容:

\1<\/\2>

See RegEX DEMO 参见RegEX DEMO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM