diff --git a/docs/03-plugins/cleanupNumericValues.mdx b/docs/03-plugins/cleanupNumericValues.mdx
index a46c5ed9..0da3dca1 100644
--- a/docs/03-plugins/cleanupNumericValues.mdx
+++ b/docs/03-plugins/cleanupNumericValues.mdx
@@ -18,4 +18,4 @@ svgo:
default: true
---
-Rounds numeric values, and removes the unit when it's `px` as this is the default.
+Rounds numeric values, removes the unit when it's `px` as this is the default, and removes redundant spaces around and between numbers.
diff --git a/plugins/cleanupNumericValues.js b/plugins/cleanupNumericValues.js
index 03714097..357e887e 100644
--- a/plugins/cleanupNumericValues.js
+++ b/plugins/cleanupNumericValues.js
@@ -39,6 +39,7 @@ export const fn = (_root, params) => {
if (node.attributes.viewBox != null) {
const nums = node.attributes.viewBox.split(/\s,?\s*|,\s*/g);
node.attributes.viewBox = nums
+ .filter((value) => value.length != 0)
.map((value) => {
const num = Number(value);
return Number.isNaN(num)
@@ -54,7 +55,7 @@ export const fn = (_root, params) => {
continue;
}
- const match = value.match(regNumericValues);
+ const match = regNumericValues.exec(value);
// if attribute value matches regNumericValues
if (match) {
diff --git a/test/plugins/cleanupNumericValues.03.svg.txt b/test/plugins/cleanupNumericValues.03.svg.txt
new file mode 100644
index 00000000..976d8046
--- /dev/null
+++ b/test/plugins/cleanupNumericValues.03.svg.txt
@@ -0,0 +1,5 @@
+
+
+@@@
+
+