kb_ kb_ - 2 months ago 10
C# Question

regex percentage with 8 decimal points after the comma

I want to manage the inserted percentage value over a regex "function" and it should looks like this:



or 100,10000000

I've tried to do it with the following regex but it wount work, have someone a solution to solve the "problem" ? The percentage value should always have 8 decimal points after the comma

this.Percentage.AutoHeight = false;
this.Percentage.Mask.EditMask = "(100(\\R.0{1,2})?)|((\\d{1,2}(\\R.\\d{1,8})?))";
this.Percentage.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.RegEx;
this.Percentage.Name = "Percentage";

for the ________ after the comma should be 8 time a 0

enter image description here


Use this regex:


With that regex you have a number, with 8 decimal points after the comma: XX...XXX,XXXXXXXX and X is element of {0,1,2,3,4,5,6,7,8,9}

To archive that the value before the comma can't be bigger than 100 you have to change the regex into this: