Skip to content

Commit 41c1b34

Browse files
authored
Merge pull request #3386 from PHPOffice/NumberFormatMask-Tweak
Adjust regexp for an explicit 0 for a decimals value when using Currency and Accounting locale masks
2 parents de01e59 + c70de6b commit 41c1b34

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)