[英]Repeat string in apache velocity
I want to define a custom file template for my PhpStorm IDE and want to use #set
directive to define a string variable based on $NAME
我想为我的 PhpStorm IDE 定义一个自定义文件模板,并希望使用
#set
指令来定义基于$NAME
的字符串变量
the name is foo/bar/baz
I want to count /
and create $RELATIVE_PATH
variable ../../../
名称是
foo/bar/baz
我想计算/
并创建$RELATIVE_PATH
变量../../../
How can I create $RELATIVE_PATH
based on $NAME
?如何根据
$NAME
创建$RELATIVE_PATH
?
Use the Java String.replaceAll()
method:使用 Java
String.replaceAll()
方法:
#set($RELATIVE_PATH = "$NAME.replaceAll('[^/]+', '..')/")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.