Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Velocity Template Language の文字列の一部を別の文字列に置き換えたいです。
例えば:
#set($a = "Hello") #set($b = "+")
Hello の ll を ++ に置き換えたい。出力は He++o である必要があります
私を助けてください
ありがとうキショア
デフォルトでは、Java String オブジェクトのメソッドを使用できます。
#set( $a = "Hello" ) #set( $b = $a.replace("l", "+") ) ${b}
He++oを生成し、速度変数をメソッド呼び出しの引数として使用することもできます。
#set( $a = "Hello" ) #set( $b = "+" ) #set( $c = $a.replace("l", ${b}) ) ${c}