Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace new line character in freemarker

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>")>

which worked in Java, but not in freemarker. How can I do this?

like image 931
mario595 Avatar asked Apr 19 '13 15:04

mario595


1 Answers

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')>
like image 102
mario595 Avatar answered Sep 29 '22 18:09

mario595