问题
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