0

It seems that this code is not wokring on velocity template,

#foreach ($req in $Project.Requirements)        
{
    #set($brRegex = "<[^>]*>")          

    #set ($sr = $req.StatedRequirement.replaceAll($brRegex, " "))   
    "SR":"$sr"
}#if($velocityHasNext)nonext #end
#end

as for $req.StatedRequirement I've tested against the strings below

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/>

on the $sr the
and other html tags should all be replaced on the output but they're still there, what could be wrong? Thanks!

bherto39
  • 1,516
  • 3
  • 14
  • 29

1 Answers1

0

The replacements on your test string are working for me.

It's maybe due to the fact that you're not looping on all elements, since $velocityHasNext has been deprecated in 1.7 and has disappeared in 2.x.

The correct syntax is now:

#if ($foreach.hasNext)
Claude Brisson
  • 4,085
  • 1
  • 22
  • 30
  • hey Claude, tnx for testing I'm getting something inside the #foreach but the html tags are not replaced. the replaceAll($brRegex, " ") should strip all <> right? we're using velocity 1.7, the #if($velocityHasNext)nonext #end could be removed it just adds a character at the end for each loop. – bherto39 Jun 23 '20 at 03:33