Format the results of regexReplace handlebar

This is the current handlebar:

{{regexReplace SaleAmount "" "^0+" "g"}}

This removes the leading zeros from an input value and it does work. An example input is 000018.63 which results in 18.63.

The problem is that I need to ensure that an input of 00000.00 results in 0.00, not .00 .

Any thoughts?

Could you just do this?

{{toFixed (add SaleAmount 0) 2}}

or this:

{{#compare (add SaleAmount 0) "===" 0}}0.00{{else}}{{regexReplace SaleAmount "" "^0+" "g"}}{{/compare}}

:man_facepalming:

Sometimes the simplest solution is the best. toFixed did the trick!

Thanks, Tyler.

1 Like