简体   繁体   English

apache 速度中的重复字符串

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM