Javascript 正则表达式来修剪文本中的新行并附加分隔符

Javascript 正则表达式来修剪文本中的新行并附加分隔符,javascript,html,regex,Javascript,Html,Regex,使用表格从word文档复制内容 复制的HTML如下所示: 这在上表中 \n\n 这是下表 尝试下面的正则表达式,这将有助于: html.replace(/<\/table>(\\n)*$/g, "</table><br/>").replace(/^<table/g, "<br/><table"); html.replace(/(\\n)*$/g,“”)。replace(/^尝试下面的正则表达式,这将有帮助: html.replace

使用表格从word文档复制内容

复制的HTML如下所示:

这在上表中
\n\n
这是下表

尝试下面的正则表达式,这将有助于:

html.replace(/<\/table>(\\n)*$/g, "</table><br/>").replace(/^<table/g, "<br/><table");

html.replace(/(\\n)*$/g,“
”)。replace(/^尝试下面的正则表达式,这将有帮助:

html.replace(/<\/table>(\\n)*$/g, "</table><br/>").replace(/^<table/g, "<br/><table");

html.replace(/(\\n)*$/g,“
”).replace(/^@Mohit的答案几乎正确,请使用:


html.replace(/(\n)*$/g,“
”).replace(/^@Mohit的答案几乎正确,请使用:


html.replace(/(\n)*$/g,“
”).replace(/^Try
html=html.replace(/^\s+\s+$/gm)”)
是否只在表的结尾处使用它,而不用于其他html标记?html.replace(/(\\n)*$/i,“
”).replace(/^/i,
”);Try
html=html.replace(/^\s+\s+$/gm
html.replace(/(\\n)*$/i,“
”)。replace(/^/i,“
”)是否只在表格结尾处使用它,而不用于其他html标记;表中断前后都是必需的。嵌套表不需要中断。您尝试了我上次更新的那一个?请检查并让我知道它失败在哪里?仅适用于此。不适用于其他两个。表中断前后都是必需的。嵌套表不需要中断。您尝试了我上次更新的那一个?请让我知道失败在哪里?只为这个工作,不为其他两个工作让我们。