我正在尝试使用正则表达式在 Notepad++ 中使用 Find&Replace 更改一些 XML。
这是我要捕获的特定 XML:
<category name="Content Server Categories:FOLDER:test category">
<attribute name="test attribuut"><![CDATA[test]]></attribute>
<attribute name="test attribuut1"><![CDATA[test1]]></attribute>
</category>
遵循“查找”正则表达式完成工作(现在):
<(category) name="Content Server Categories:(.+?)">(.+)</(category)>
现在我需要用这个替换 XML:
<category-FOLDER:testcategory name="Content Server Categories:FOLDER:test category">
<attribute name="test attribuut"><![CDATA[test]]></attribute>
<attribute name="test attribuut1"><![CDATA[test1]]></attribute>
</category-FOLDER:testcategory>
目前我尝试使用这个'REPLACE BY'正则表达式:
<($1-$2) name="Content Server Categories:($2)">($3)</($1-$2)>
但这会产生以下输出:
<category-FOLDER:test category name="Content Server Categories:FOLDER:test category">
<attribute name="test attribuut"><![CDATA[test]]></attribute>
<attribute name="test attribuut1"><![CDATA[test1]]></attribute>
</category-FOLDER:test category>
如您所见,我得到category-FOLDER:test category 而不是category-FOLDER:testcategory
需要删除空格..
问题是输入可能看起来不同。现在是这样的:
<category name="Content Server Categories:FOLDER:test category">
但它也可能看起来像这些例子:
<category name="Content Server Categories:FOLDER1:FOLDER2:test category">
<category name="Content Server Categories:FOLDER NAME:test category">
<category name="Content Server Categories:FOLDER NAME: FOLDER NAME1:test category">
<category name="Content Server Categories:FOLDER:test category name">
...
如何正确捕获所有这些并删除空格?
编辑:差点忘了,
'. Matches newline' is __ON__