Regex Widget

Result:

How to Use This Regex Generator

Mode selects how you define the acceptable numbers the regex should match.

Leading Zero: Choose Reject (only ".25"), Optional (".25" or "0.25"), or Required (only "0.25") for decimals < 1.

Nominal: Base (non-negative) number. For values < 1 do not prefix with a leading zero (use .25, not 0.25).

Tolerance / - Tolerance / + Tolerance: Non-negative adjustments. Decimals are allowed (again, no leading zero if < 1).

Range: Pattern a-b (a ≤ b). Integers or decimals allowed. Endpoints may use different decimal lengths; the larger precision is applied to the whole interval. Leading-zero policy applies to values < 1.

Precision behavior: The generated pattern anchors the entire input (ignores surrounding whitespace) and, for tolerance ranges with decimals, may include values at the entered precision and optionally one extra decimal place to ensure coverage of boundary expansions.

Submit builds the regex.

Reset clears fields (the chosen mode is preserved). Editing any field clears the previous result to avoid stale output.

Result shows the final anchored regex (no units).

Copy Regex becomes enabled after generation; click to copy to clipboard.

Notes: Only non-negative numbers are supported. Inputs are normalized exactly as typed—extra trailing zeros are significant for precision. No thousands separators. Errors display in place of the regex.