You can use regular expression with a capturing group:
<#assign string="first-second-third-100201" />
${string?replace("-([^-]*)$", "/$1", "r")}
Output is first-second-third/100201
.
In the regular expression, the ([^-]*)
capture the substring after the last -
. In the replacement string, the $1
is replaced by the value of the captured group.