Simple Validation Problem Using Regex

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
 
K

Kevin Spencer

(?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.
 
P

Phillip Vong

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top