Looked into it, this is a bug in the community commons module. You can apply the following patch to solve this (patch will be included in the next release as well):
replace javasource/communitycommons/StringUtils.java lines 93-97:
if (match.group(1) != null)
value = String.valueOf(Core.getConfiguration().getConstantValue(path));
else
value = ORM.getValueOfPath(context, substitute, path, datetimeformat);
regexMatcher.appendReplacement(resultString, HTMLEncode ? HTMLEncode(value) : value);
by
if (match.group(1) != null)
value = String.valueOf(Core.getConfiguration().getConstantValue(path));
else
value = ORM.getValueOfPath(context, substitute, path, datetimeformat);
value = Matcher.quoteReplacement(value);
regexMatcher.appendReplacement(resultString, HTMLEncode ? HTMLEncode(value) : value);
(only the 5th line changed)
It looks like $ is a special character. Try to escape it, maybe '\$'