ConstnumericRegex.exec("1") // [ "1", null, "1", null, null, null, null ]
numericRegex.exec("1.23") // [ "1.23", null, "1", ".23", null, null, null ]
numericRegex.exec("1 2/3") // [ "1 2/3", null, "1", " 2/3", null, null, " 2" ]
numericRegex.exec("2/3") // [ "2/3", null, "2", "/3", null, null, null ]
numericRegex.exec("2 / 3") // [ "2 / 3", null, "2", " / 3", null, null, null ]
numericRegex.exec("-2 1/3") // [ "-2 1/3", "-", "2", " 1/3", null, null, " 1" ]
numericRegex.exec("1e3") // [ "1e3", null, "1", "e3", "e3", null, null ]
numericRegex.exec("1.5e-3") // [ "1.5e-3", null, "1", ".5e-3", null, "e-3", null ]
numericRegex.exec("1,000") // [ "1,000", null, "1,000", null, null, null, null ]
This pattern and numericRegexWithTrailingInvalid are maintained as two separate
literals and must be kept in sync. They differ only in the tail: $ here versus
(\s*[^.\d/].*)? there. src/index.test.ts asserts that equality.
Captures the individual elements of a numeric string. Commas and underscores are allowed as separators, as long as they appear between digits and are not consecutive.
Capture groups:
0"2 1/3"from"2 1/3"1-or+)"-"from"-2 1/3"2"2"from"2 1/3";"1"from"1/3"3" 1/3"from"2 1/3";".23"from"1.23";".5e3"from"1.5e3"4"e3"from"1e3"5"e-3"from"1.5e-3"6" 2"from"1 2/3"Groups 4–6 are subgroups of group 3 and are not used directly by numericQuantity; only groups 1–3 are consumed.
Capture groups 2 and 3 may include comma/underscore separators.