For WPF control TextEdit from DevExpress15.2, I need an input mask for a fractional number (preferably a given integer / fractional part width), and never displaying the fractional separator character if the user does not write it.
The standard version of the numeric Numeric mask like n not satisfied with the fact that even if we enter an integer, the fractional part separator is still displayed at the end.
Setting MaskUseAsDisplayFormat="False" MaskSaveLiteral="False" values MaskUseAsDisplayFormat="False" MaskSaveLiteral="False" did not give such a result.
I decided to implement it using regular expressions as for a fractional number, thus:
[-+]?\d{1,32}[.,]?\d{0,6} (we do not write special characters for the beginning / end of the line, since they are already implied in DevExpress; in case of entering an incorrect fraction separator character, I have a validation of values)
The problem is that it should skip values like ( 120,345 , 102,345 , 0,123 ) and at the same time DO NOT skip like 012,345 - i.e. A mask is required for a fractional number NOT starting with 0 if there are other digits in the integer part.
Tell me how to win :) not necessarily regular.
^[-+]?(?!0+[1-9])\d{1,32}[.,]?\d{0,6}$- Wiktor Stribiżew^,$- they are automatically applied in the input control mask, you just don’t need to write them explicitly. - Alias