Exemplo n.º 1
0
        protected override NodeResultBuilder GetValue()
        {
            //Expression to match the number, without sign
            string number = InputLimitBy.Value switch
            {
                LimitType.Value => GetIntegerRangeRegex(InputValueRange.Min ?? 0, InputValueRange.Max ?? 0),
                LimitType.Digits => (InputDigitRange.Min ?? 0) == InputDigitRange.Max ?
                $"\\d{{{InputDigitRange.Min}}}" :
                $"\\d{{{InputDigitRange.Min ?? 0},{InputDigitRange.Max}}}",
                LimitType.Nothing => "\\d+",
                _ => "\\d+",
            };
            var builder = new NodeResultBuilder(number, this);

            //Add non-capturing group to make the alternation work
            if (number.Contains('|'))
            {
                builder.AddNonCaptureGroup(this);
            }

            if (InputLeadingZeros.Checked)
            {
                builder.Prepend("0*", this);
            }

            AddSign(builder);

            return(builder);
        }