【发布时间】:2016-01-04 23:00:03
【问题描述】:
我是使用 XML 的新手,没有受过太多培训。我正在尝试正确格式化自定义报告中的文本。我有这一行:
.replace(/(<([^>]+)>)/ig, "\n")
并希望完全了解它在做什么。我知道一个新行正在替换括号中的内容。具体来说,这是在寻找什么?
([^>]+)>)
编辑(来自 cmets):
这是完整的表达式(为便于阅读重新格式化)。
<expression name="expression" type="javascript">
(
dataSetRow["Question_Employee_Comment"] +
dataSetRow["Question_Manager_Comment"]
)
.replace(/(<([^>]+)>)/ig, "\n")
.replace(/null/ig, "")
.replace(/&amp;/g, "&")
.replace(/&#39;/g,"'")
.replace(/&nbsp;/g," ")
.replace(/•/g,'\n•')
</expression>
这里是这个表达式正在查看的 XML(为便于阅读而包装):
<wd:Question_Employee_Comment>
<p>I don't even know where to start... Cupid wasn't @ his desk on 2/14/2015
and I'm really upset because I've been really patient with his personal needs.
Santa &amp; I sat him down and have discussed why his attendance is important
to success.</p><p></p><p>He's been absent
on:</p><ul><li>3/19/15</li><li>March 20,
2015</li><li>05/01/2015</li>/ul><p></p><p>All
additional dates will be documented.</p>
</wd:Question_Employee_Comment>
【问题讨论】:
-
是对的 .replace(/(<([^>]+)>)/ig, "\n")?不会是 .replace(/(]+)>)/ig, "\n")?
标签: javascript regex xml birt