sivaprasad9394
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_IF(!#content.isEmpty)$
 $CMS_IF(#content.toString.trim.contains("</ul>"))$	
  $CMS_VALUE(#content.toString.trim.replaceAll("</ul>[\n\r\s]+<br>", "</ul>"))$
$CMS_ELSE$
  $CMS_VALUE(#content)$<br />
 $CMS_END_IF$
$CMS_END_IF$

 

 

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

Thank you.

Labels (2)
Tags (2)
0 Kudos
1 Reply
pjodeleit
e-Spirit employee

Re: How to use regx in FS Format Template?

Hi,

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

 

Peter
0 Kudos