DecimalsRangeRegexpGenerator

Main parameters

They impact the decimal numbers that can be written.

Efficient for a step that is a power of your base (default: 10). Otherwise experimental, since the general algorithm I use generates regular expressions that becomes too big most of the time. Try 111 = 7 in base 01, or 5 or 0.5 in base 0123456789 for an example where it works without being excessively long. Try 0.25 in base 0123456789 for an example where the current algorithm is too dumb to compute a short regular expression.


More optional parameters

They impact the formatting of the decimal numbers that can be written.
Here you can break out of base ten, and use any encoding of numbers using positional notation with fixed base.

I like "creeping featurism". Without sabotage, it is easy to add as many features as you like, for the good of everyone. Blaming creeping featurism for high maintenance cost is hypocrisy.

A string that defaults to "0123456789"; you may use "01" (base 2) or "0123456789abcdef" (base 16) for example, or even "five" for base four ;). ("f" would be your zero, "i" your unit, etc.)

A string that defaults to "."; you may use "," or ".," for example.

A string that defaults to "+"; you may use "p" for example, or "pl" if you would like to use "p" or "l" as you wish.

A string that defaults to "-"; you may use "m" for example, or "mn" if you would like to use "m" or "n" as you wish.

Spacing

You may try exactly one non-breakable space here, for example.

With both min and max at 3, you can have spacing like thousands separators.

More strange things

The generated regular expressions sometimes need to use groups, that are not positive or negative look-ahead or look-behind. It is used either for alternatives or repetitions. In that case, one may freely choose to use simple capturing group or non-capturing group.

You do not need it, you can use "Min number of digits before decimal separator" = 0 or empty and a max is given. Note that when no min and no max are given, it defaults to "+" or "{1,}" that disallow leading decimal separator. Because "+" is the most sensible choice for most use cases.

You do not need it, you can use "Min number of digits after decimal separator" = 0 or empty and a max is given. Note that when no min and no max are given, it defaults to "+" or "{1,}" that disallow trailing decimal separator. Because "+" is the most sensible choice for most use cases. If you want to make sure that no trailing decimal separator is allowed, while specifying a max number of digits after decimal use "Min number of digits after decimal separator" = 1 with or without "Do not apply min number of digits after decimal part if there is no decimal part".



Error message


Result


Test your result

Note that an empty string will always validate. If you want to exclude an empty string, you have to add "required" as an attribute to your HTML input.


Detail of step calculus




©Copyright 2022 Laurent Lyaudet
GNU AGPL : this HTML file you're currently viewing must contain all the source code, other files of the repository should be here, or on GitHub here .