Occasional Collector

How to use regx in FS Format Template?

Hello Team,

I have to replace some html tags in the page content. Like </ul><br> and replaceAll() with </ul> only.

For me in normal Java code below are working.


p_block_code is a String
System.out.println(p_block_code.replaceAll("(.*)</ul>\r\n<br>(.*)", "</ul>"));
System.out.println(p_block_code.trim().replaceAll("<\\/ul>[\\n\\r\\s]+<br>", "</ul>"));


How to make it wok inside FS template? A i missing any parsing here.


  $CMS_VALUE(#content.toString.trim.replaceAll("</ul>[\n\r\s]+<br>", "</ul>"))$
  $CMS_VALUE(#content)$<br />



For the above FS code is not working properly for replaceAll() method.

Thank you.

0 Kudos
1 Reply
Crownpeak employee


your code is working perfectly fine. I wouldn't recommend such usage and it isn't efficient to do it this way, but it works.
What I see on a first glance that the Java code and the template code differs, perhaps you double check this?

Otherwise please use a simpler test code and work your way from there.
Eg something like this:

$CMS_SET(s, "x</ul>\n\n<br>x")$
$CMS_VALUE(s.replaceAll("</ul>[\n\r\s]+<br>", "</ul>"))$


0 Kudos