正则表达式替换所有在速度模板上不起作用



似乎这段代码在速度模板上没有摇摆,

#foreach ($req in $Project.Requirements)        
{
#set($brRegex = "<[^>]*>")          
#set ($sr = $req.StatedRequirement.replaceAll($brRegex, " "))   
"SR":"$sr"
}#if($velocityHasNext)nonext #end
#end

至于$req。声明要求 我已经针对下面的字符串进行了测试

Some text here [Selection (one or more): organizational analysis, independent thirdparty analysis, organizational penetration testing, independent third-party penetration testing] of [Assignment: organization-defined supply chain elements, processes, and actors] associated with the information system, system component, or information system service.<br/>
<br/>
Other Text<br/>
<br/>
This control enhancement addresses analysis and/or testing of the supply chain, not just delivered items. Supply chain elements are information technology products or product components that contain programmable logic and that are critically important to information system functions. Supply chain processes include, for example: <br/>
<br/>
(i) hardware, software, and firmware development processes; <br/>
<br/>
(ii) shipping/handling procedures;<br/>
<br/>
(iii) personnel and physical security programs; <br/>
<br/>
(iv) configuration management tools/measures to maintain provenance; or <br/>
<br/>
(v) any other programs, processes, or procedures associated with the production/distribution of supply chain elements. <br/>
<br/>
blah blah. <br/>

在输出$sr
和其他 HTML 标签都应该被替换,但它们仍然存在,可能有什么问题?谢谢!

测试字符串上的替换对我有用。

这可能是因为您没有循环所有元素,因为$velocityHasNext在 1.7 中已被弃用,并在 2.x 中消失。

现在正确的语法是:

#if ($foreach.hasNext)

最新更新