velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shinobu Kawai <shinobu.ka...@gmail.com>
Subject Re: Issue with #set/replaceAll
Date Mon, 06 Sep 2004 16:14:56 GMT
Oops, didn't reply to the list...

Hi Sitaram,

> I would want to replace all occurrences of CONTAINER/test with $Map/test
> Finally when I print $test it should look
> "My String is $Map/test"

> > > #set ($try = "My String is CONTAINER/test")
> > > #set ($abc = "CONTAINER/test")
> > > #set ($def = '$Map/test)
> > > #set ($test = $try.replaceAll($abc,$def)
> > > Test is $test
What you have here, is a regex problem, not a Velocity problem.  Since
"$" is a special character for replacements, you have to escape them to
use it as is.
   http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Matcher.html#appendReplacement(java.lang.StringBuffer,
java.lang.String)

Try the following:
   #set ($def = '\$Map/test')

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai(shinobu.kawai@gmail.com)

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message