Why "\ d + {1,4} (?: [.,] \ D {1,4})?" in RegularExpressionValidator throws Exception: "Nested quantifier {"

I have

<asp:RegularExpressionValidator ValidationExpression="\d+{1,4}(?:[.,]\d{1,4})?" />

      

but it doesn't work, the parser throws an ArgumentException:

parsing "\ d + {1,4} (?: [.,] \ d {1,4})?"

Nested quantifier {.

Where is my mistake? I want to allow the type of line xxxx,xxxx

- from 1 to 4 digits and decimal digits are required, such as 1000

, 99,99

, 0,2498

, etc.

+2


a source to share


3 answers


I think this should do it:



\d{1,4}(?:,\d{1,4})?

      

+2


a source


This looks wrong:

\d+{1,4}

      

Should be:



\d{1,4}

      

+

means "one or more" and {1,4}

means one to four. They cannot be used together as it makes no sense.

+5


a source


I think what you want

[.,]?

      

Instead

?:[.,]

      

0


a source







All Articles