Replace new line character in freemarker

守給你的承諾、 提交于 2019-12-08 16:14:05

问题


Is there any way to replace the new line character on free marker? I am trying this:

<#assign str = str?replace("(\r\n)+", "</p><p>")>

wich worked on java, but not in freemarker. How can I do this?

Thanks in advance.


回答1:


Ok, I found the problem. The replace function needs to know if the expresion is a regex, so I had to add 'r' as a parameter

<#assign str = str?replace("(\r\n)+", "</p><p>",'r')>


来源:https://stackoverflow.com/questions/16108107/replace-new-line-character-in-freemarker

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!