Search code examples
javafreemarker

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

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