Skip to content

Commit c70de6b

Browse files
committed
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
1 parent de01e59 commit c70de6b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/PhpSpreadsheet/Style/NumberFormat/Wizard/Accounting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function getLocaleFormat(): string
5555
$formatter = new Locale($this->fullLocale, NumberFormatter::CURRENCY_ACCOUNTING);
5656
$mask = $formatter->format();
5757
if ($this->decimals === 0) {
58-
$mask = (string) preg_replace('/\.0*/', '', $mask);
58+
$mask = (string) preg_replace('/\.0+/miu', '', $mask);
5959
}
6060

6161
return str_replace('¤', $this->formatCurrencyCode(), $mask);

src/PhpSpreadsheet/Style/NumberFormat/Wizard/Currency.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function getLocaleFormat(): string
7272
$formatter = new Locale($this->fullLocale, NumberFormatter::CURRENCY);
7373
$mask = $formatter->format();
7474
if ($this->decimals === 0) {
75-
$mask = (string) preg_replace('/\.0*/', '', $mask);
75+
$mask = (string) preg_replace('/\.0+/miu', '', $mask);
7676
}
7777

7878
return str_replace('¤', $this->formatCurrencyCode(), $mask);

0 commit comments

Comments
 (0)