'how to remove a sequence from string in ftl

I am working on a project where I need to put away some part of string, not to be visible on front page. I am working with ftl.

Example:

there is a string like:

<#assign valueToShow= "#99#testing,#777#test">

I need to show the values without part #digits#. The final result need to be like this:

"testing,test"

How can I do that in FTL?

Thanks...



Solution 1:[1]

valueToShow?replace("#[0-9]+#", "", "r"), where 3rd "r" parameter means that what you replace is a regular expression.

Solution 2:[2]

The string class offers an easy way to do this:

String valueToShow = rawString.replaceFirst("#\\d+#", "")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ddekany
Solution 2 Ryan