- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ01-21-2022
03:16 AM
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
- Labels:
-
regx
-
replaceAll
- Tags:
- regx
- replaceall
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ01-26-2022
09:27 AM
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

