Reputation: 4101
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
the name is foo/bar/baz
I want to count /
and create $RELATIVE_PATH
variable ../../../
How can I create $RELATIVE_PATH
based on $NAME
?
Upvotes: 0
Views: 142
Reputation: 4130
Use the Java String.replaceAll()
method:
#set($RELATIVE_PATH = "$NAME.replaceAll('[^/]+', '..')/")
Upvotes: 1