如何通过使用javascript替换功能在每个xml结束标记后输入换行符?

问题描述 投票:0回答:1

[我在格式化xml代码时使用了以下javascript替换功能。

xml = xmll.replace(/<\/?[0-9]{1,}>/g, '');

但是即使我也使用以下功能来创建新行,也不会创建换行符。

xml = xmll.replace(/<\/?[0-9]{1,}>/g, '\n');

仍然在关闭xml标签后没有创建换行符或换行。有人知道应该怎么做吗?

javascript xml replace format str-replace
1个回答
0
投票

尝试一下。

xml = xmll.replace(/(<\/?.*?>)/g, '$1\n');
© www.soinside.com 2019 - 2024. All rights reserved.