我想删除文件中除匹配项目之外的所有数据。我正在使用记事本++
我想保留 <w:t> 和 </w:t> 标签之间的所有内容,删除其余内容。
样本数据:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"
xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex"
xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex"
xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex"
xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex"
xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex"
xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex"
xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:oel="http://schemas.microsoft.com/office/2019/extlst"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"
xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml"
xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml"
xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex"
xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid"
xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml"
xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash"
xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex"
xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"
xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk"
xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14">
<w:body>
<w:p w14:paraId="66109096" w14:textId="49D9B7F3" w:rsidR="00D96595" w:rsidRPr="00D96595" w:rsidRDefault="00D96595" w:rsidP="00D96595">
<w:pPr><w:pStyle w:val="Heading1"/>
<w:spacing w:before="13" w:line="259" w:lineRule="auto"/>
<w:ind w:left="990" w:right="0"/>
<w:jc w:val="left"/>
<w:rPr>
<w:spacing w:val="-2"/><w:sz w:val="96"/>
<w:szCs w:val="96"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:spacing w:val="-2"/>
<w:sz w:val="72"/>
<w:szCs w:val="72"/>
</w:rPr>
<w:t xml:space="preserve">
</w:t>
</w:r>
<w:bookmarkStart w:id="0" w:name="_Toc147064115"/>
<w:r w:rsidRPr="00D96595">
<w:rPr><w:spacing w:val="-2"/>
<w:sz w:val="96"/>
<w:szCs w:val="96"/>
</w:rPr>
<w:t>Advanced</w:t>
</w:r>
<w:bookmarkEnd w:id="0"/>
</w:p>
该代码
<w:t>.+?</w:t>(*SKIP)(*F)|.+?
未找到任何匹配项。
您提到的 RegEx 代码在 Notepad++ 版本 8.5.6 中对我来说工作得很好。我针对带有换行符的用例稍微修改了代码:
您可能在视觉上错过了光标位置处的单个字符匹配。当您单击“查找下一个”按钮(例如使用“查找”对话框)时,它将单独突出显示每个字符。因此,尝试使用Strg+M输入上面的正则表达式代码,然后单击“全部标记”,看看会发生什么,如下面的屏幕截图所示。请注意,这取决于您设置中的颜色偏好。
单击Replace All将导致: