commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Brice <>
Subject Re: Commons Lang substitution
Date Sat, 14 Nov 2015 21:25:55 GMT
I could be wrong, but I do believe StrSubstitor requires a prefix and
suffix. I don't think the class will replace variables that aren't in the
map either, unless you write a custom StrLookup that returns an empty
string for variables not previously defined.
On Sat, Nov 14, 2015 at 11:02 AM Alex Soto <> wrote:

> Hi I have two special requirements that I think that Common-Lang
> StrSubstitutor does not cover, but I would like to know if it is correct or
> not.
> The first requirement is that I would like to know if there is a way to
> make StrSubstitutor works with using simple character as prefix and no
> suffix. For example:
> "This is my $name and I am happy"
> I have tried  by using new StrSubstitutor(map, "$", "") and
> StrSubstitutor(map, "$", " ") but no luck.
> I have tried with commons-lang and commons-lang3.
> The second one is that I would like to know if there is a way to force that
> in case of no substitution found, the var is replaced with white space
> instead of untouch it.
> Thank you very much for your attention.
> Alex.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message