Replace a Substring of a String in Velocity Template Language

By default you can use the methods of the Java String object:

#set( $a = "Hello" )
#set( $b = $a.replace("l", "+") )
${b}

will produce He++o and you can also use velocity variables as arguments to your method calls, e.g.:

#set( $a = "Hello" )
#set( $b = "+" )
#set( $c = $a.replace("l", ${b}) )
${c}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)