A.A
A.A

Reputation: 4101

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

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

Answers (1)

Claude Brisson
Claude Brisson

Reputation: 4130

Use the Java String.replaceAll() method:

#set($RELATIVE_PATH = "$NAME.replaceAll('[^/]+', '..')/")

Upvotes: 1

Related Questions