Reg Expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was wondering if anyone knew how to write a regular expression which
validated that a field was 200 or less characters long.
Its this part i'm interested in working out. Can someone help me please.

ValidationExpression="^{0,200}$"

<asp:regularexpressionvalidator id="Regularexpressionvalidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="Outcomes cannot be more than 200
characters long"
ValidationExpression="^{0,200}$">*</asp:regularexpressionvalidator>
 
Stephen said:
I was wondering if anyone knew how to write a regular expression which
validated that a field was 200 or less characters long.
Its this part i'm interested in working out. Can someone help me please.

ValidationExpression="^{0,200}$"

<asp:regularexpressionvalidator id="Regularexpressionvalidator1"
runat="server"
ControlToValidate="TextBox1" ErrorMessage="Outcomes cannot be more than 200
characters long"
ValidationExpression="^{0,200}$">*</asp:regularexpressionvalidator>

You are close: it should be "^.{0,200}$" (mind the ".")

The {0,200} means "the previous (sub)expression, repeated between
0 and 200 times", so you need to provide an expression to repeat.
The "." means "any character".

A note: by "repeated" I do not mean that the mach should be
up to 200 identical characters, but that the match-expression
"." is repeated 200 times.
 
Back
Top