commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: Commons Lang substitution
Date Mon, 16 Nov 2015 19:12:07 GMT
Hello,

2015-11-14 22:25 GMT+01:00 Anthony Brice <anthonybrice@lateachiever.com>:

> 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.
>

Yes, this is correct. The replace with blank could be implemented using a
custom StrLookup. However, it is not possible to configure a StrSubstitutor
to use only a starting character.

Benedikt


> On Sat, Nov 14, 2015 at 11:02 AM Alex Soto <asotobu@gmail.com> 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.
> >
>



-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

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