Simple Validation Problem Using Regex

  • Thread starter Thread starter Phillip Vong
  • Start date Start date
P

Phillip Vong

I'm using VS2005 programming in VB.Net.

I have a simple aspx page. In the Insert mode, I have a textbox with a
simple RegularExpressionValidator set to not accept more than 1000
characters. I'm using the expression ".{1,1000}" w/o the quotes and I
thought this would work. The DB table for this Column is set to
varchar(1000).

This works fine as long as I keep typing and it's under 1000 characters, but
as soon as I hit the RETURN key and start typing again, the validator thinks
I'm over 1000 characters. This happens even if I just type 4 characters and
then hit Return.

I've checked http://regexlib.com, but couldn't find the answer.

Can someone tell me what I'm doing wrong. I have to be able to let my users
enter the RETURN key.

Thanks in advance.
Phil
 
(?s).{1,1000}

The dot character class by default does not include newlines. When you hit
the ENTER key, the match is negated due to the insertion of a newline. The
"(?s)" directive in the regular expression indicates that it should include
newlines.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

If the Truth hurts, wear it.
 
Thanks Kevin!!!


Kevin Spencer said:
(?s).{1,1000}

The dot character class by default does not include newlines. When you hit
the ENTER key, the match is negated due to the insertion of a newline. The
"(?s)" directive in the regular expression indicates that it should
include newlines.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

If the Truth hurts, wear it.
 
Back
Top