<p>我有一个“xml文件”文件,其中有一些不需要的字符</p>
<pre><code><data>
<tag>blar </tag><tagTwo> bo </tagTwo>
some extra
characters not enclosed that I want to remove
<anothertag>bbb</anothertag>
</data>
</code></pre>
<p>我认为下面的非贪心替换将删除<code><sometag></sometag></code>中没有正确封装的字符</p>
^{pr2}$
<p>此正则表达式似乎只找到<code>[[]]</code>中<code>[[]]</code>所指示的位置
我做错什么了?在</p>
<p><strong>编辑:</strong>
这个问题的动机已经解决了(参见注释,我在xml文件中有一个错误,导致它无法解析-它与我要删除的字符无关)。然而,我仍然很好奇regex是否可行(以及我的尝试有什么问题),因此我不删除这个问题。在</p>