Connecting Tech Pros Worldwide Forums | Help | Site Map

Simple Validation Problem Using Regex

Phillip Vong
Guest
 
Posts: n/a
#1: Oct 4 '06
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



Kevin Spencer
Guest
 
Posts: n/a
#2: Oct 4 '06

re: Simple Validation Problem Using Regex


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

"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:OLBvkP25GHA.4064@TK2MSFTNGP03.phx.gbl...
Quote:
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
>

Phillip Vong
Guest
 
Posts: n/a
#3: Oct 4 '06

re: Simple Validation Problem Using Regex


Thanks Kevin!!!


"Kevin Spencer" <uce@ftc.govwrote in message
news:u933pH65GHA.3564@TK2MSFTNGP02.phx.gbl...
Quote:
(?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.
>
"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:OLBvkP25GHA.4064@TK2MSFTNGP03.phx.gbl...
Quote:
>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
>>
>
>

Closed Thread