Adjust regexp for an explicit 0 for a decimals value when using Currency and Accounting Number Format Wizards with a locale, to require at least one digit after a dot to ensure this is a decimal and not a text literal

This commit is contained in:
MarkBaker
2023-02-20 20:16:55 +01:00
parent de01e59ad0
commit c70de6b660
2 changed files with 2 additions and 2 deletions
@@ -55,7 +55,7 @@ class Accounting extends Currency
$formatter = new Locale($this->fullLocale, NumberFormatter::CURRENCY_ACCOUNTING);
$mask = $formatter->format();
if ($this->decimals === 0) {
$mask = (string) preg_replace('/\.0*/', '', $mask);
$mask = (string) preg_replace('/\.0+/miu', '', $mask);
}
return str_replace('¤', $this->formatCurrencyCode(), $mask);
@@ -72,7 +72,7 @@ class Currency extends Number
$formatter = new Locale($this->fullLocale, NumberFormatter::CURRENCY);
$mask = $formatter->format();
if ($this->decimals === 0) {
$mask = (string) preg_replace('/\.0*/', '', $mask);
$mask = (string) preg_replace('/\.0+/miu', '', $mask);
}
return str_replace('¤', $this->formatCurrencyCode(), $mask);