int calcOffset(String formatted) { if (formatted.startsWith('\$')) return formatted.length; return formatted.length - 2; }