开发者

add characters to end of line

开发者 https://www.devze.com 2023-04-08 11:18 出处:网络
How do I add </in> to the end of each line? A String contain: <ch>13</ch><in>Item 13(mon开发者_运维技巧o)

How do I add </in> to the end of each line?

A String contain:

<ch>13</ch><in>Item 13(mon开发者_运维技巧o)

<ch>14</ch><in>Item 14(mono)

<ch>15</ch><in>Item 15(mono)


To replace each line break with </in> and a line break, you could try something like this:

myString = myString.replace(/\n/g, "</in>\n");

But if the strings contains the extra white space, extra empty lines, in your example, you would probably end up with an extra </in> there too. So to get valid XML, you would probably have to do more than the above.

0

精彩评论

暂无评论...
验证码 换一张
取 消