当我有一个看起来像这样的字符串时:
"app-server/src/test/java/de/something/"
我如何获得任何可能的组合,例如:
app-server/, app-server/src, app-server/src/test, ....
显然我可以用“/”将其分割,然后我就有了一个零件数组。我还可以手动附加所有这些,然后过滤null
...
WITH split(package.path,'/')[..size(split(package.path,'/'))-1]
WITH pathParts,
pathParts[0] AS p01,
pathParts[0] + '/' + pathParts[1] AS p02,
pathParts[0] + '/' + pathParts[1] + '/' + pathParts[2] AS p03,
...
Run Code Online (Sandbox Code Playgroud)
替代:
WITH pathParts[0] AS p01,
reduce(s = pathParts[0], x IN pathParts[1..2] | s + '/' + x) + '/' AS p02,
reduce(s = pathParts[0], x IN pathParts[1..3] | s + '/' + x) + '/' AS p03,
reduce(s = pathParts[0], x IN pathParts[1..4] | …Run Code Online (Sandbox Code Playgroud)