Hi Denis and Barrie, Thank you both for your answers. Good to see, that there are always a lot of possibilities in Freemarker to solve some problems.
-- Mcihael -----Original Message----- From: Denis Bredelet <brede...@me.com.INVALID> Sent: Dienstag, 22. Oktober 2019 17:04 To: dev@freemarker.apache.org Subject: Re: Feature Request for builtin "replace" Hi Michael > On 22 Oct 2019, at 15:50, Barrie Selack <bar...@rockhopper.com> wrote: > > Michael, > > Could you use remove_begining and remove_ending? > > https://freemarker.apache.org/docs/ref_builtins_string.html#ref_builti > n_remove_ending > > Barrie > > > > On Tue, Oct 22, 2019 at 10:31 AM Riehemann, Michael < > michael.riehem...@coremedia.com> wrote: > >> Hello, >> >> I have a Feature Request for the string built-in "replace". >> >> This built-in has some additional flags, see >> https://freemarker.apache.org/docs/ref_builtins_string.html#ref_built >> in_string_flags >> >> Example: >> We have string, in which we want to remove the first and last >> appearance of a substring. >> The first one is possible, but not the last one. Or do I miss >> something here? You could use a combination of keep_before_last and keep_after_last :) — Denis. >> Code: >> <#assign testString="start some text start end some more lines end again" >> /> >> ${testString?replace("start", "", "f")} = some text start end some >> more lines end again >> >> It would be nice to have a flag "l" to get the last one. >> ${testString?replace("end", "", "l")} = start some text start end >> some more lines again >> >> >> What do you think? >> >> Thanks in advance, >> >> Michael Riehemann >>