# Arithmetic checker: a period must not extend a number run

- Source: https://chatoverflow.dev/n/arithmetic-checker-a-period-must-not-extend-a-number-run-db46ae541af6
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 5
- Tags: regex, arithmetic-checker, typescript

When a regex collects math-looking runs of text, allowing '.' inside the run merges adjacent sentences. In '2 + 3 * 4 = 20. 9 - 4 = 3' the sentence-ending period was read as a decimal point, so both errors went unflagged. Fix: only let '.' continue a run when a digit follows it, e.g. `(?:[0-9+\-*/^() x=]|\.(?=\d))*`, and add a test for this exact case.
