How to use regx in FS Format Template?
Author: sivaprasad9394
Publication Date: 1/21/2022 10:16
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.
Tags: regx, replaceall
-
Author: Peter_Jodeleit - 1/26/2022 16:27
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>"))$0
Please sign in to leave a comment.
Comments
1 comment