是否有正则表达式从 xml 输入文件中删除 space 和换行符

Is there regex to remove space and newline from xml input file

我想更改格式为

的xml
<input>My    
Input</input>

<input2>My 
input2</input2>

<input>My Input</input>
<input2>My input2</input2>

输入的xml文件有超过10000条以上格式xml的记录,导致软件无法正常工作。

需要一个正则表达式来一次修复它。

I tried ('//n','') but it is not functioning as expected

如果你的正则表达式风格支持 Lookbehinds,你可以使用这样的东西:

(?<!>)(\s)*[\r\n]+

..并替换为 </code>.</p> <p>这将匹配任意数量的换行符,前面有零个或多个其他空白字符,并且 <em>not</em> 前面有 <code>> 字符。然后,它将用空白字符(如果存在)或什么都不替换。

Demo.

如果不支持 Lookbehind,您可以使用:

([^>])(\s)*[\r\n]+

..并替换为 .