如何使用 javascript 替换功能在每个 xml 结束标记后输入换行符?
How to enter line break after every xml closing tag by using javascript replace function?
我在格式化 xml 代码时使用以下 javascript 替换函数。
xml = xmll.replace(/<\/?[0-9]{1,}>/g, '');
但是即使我也使用了以下函数来创建新行,它也没有创建换行符。
xml = xmll.replace(/<\/?[0-9]{1,}>/g, '\n');
关闭 xml 的标签后仍然没有创建换行符或换行符。谁能知道可能的解决方案是什么?
试试这个。
xml = xmll.replace(/(<\/?.*?>)/g, '\n');
我在格式化 xml 代码时使用以下 javascript 替换函数。
xml = xmll.replace(/<\/?[0-9]{1,}>/g, '');
但是即使我也使用了以下函数来创建新行,它也没有创建换行符。
xml = xmll.replace(/<\/?[0-9]{1,}>/g, '\n');
关闭 xml 的标签后仍然没有创建换行符或换行符。谁能知道可能的解决方案是什么?
试试这个。
xml = xmll.replace(/(<\/?.*?>)/g, '\n');