Regex replaceAll не работает с шаблоном Velocity - PullRequest
0 голосов
/ 17 июня 2020

Кажется, что этот код не работает с шаблоном скорости,

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

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

как для $ req.StatedRequirement, я тестировал строки ниже

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 the и другие теги html должны быть заменены на выходе, но они все еще там, что может быть не так? Спасибо!

1 Ответ

0 голосов
/ 18 июня 2020

У меня работают замены в вашей тестовой строке.

Возможно, это связано с тем, что вы не выполняете цикл для всех элементов, поскольку $velocityHasNext устарел в версии 1.7 и исчез в 2 .x.

Теперь правильный синтаксис:

#if ($foreach.hasNext)
...