If I have a regexvalidator in a webform with a validation expression of
^[+]?[0-9]\d* and I put the text 2d in a text box being validated by this
validator, the validator fires.
This regex is a simple one that only allows the user to enter integer
values.
However, if I do this on the server side like this
Regex rx = new Regex(@"^[+]?[0-9]\d*");
Match mt = rx.Match("2d");
I get success!!!! why?? is there an option I should be setting? 5 1077
I think the regularexpressionvalidator automatically puts ^ at the start and
$ at the end...2d DOES match ^[+]?[0-9]\d* but it DOES NOT match
^[+]?[0-9]\d*$ (note the extra $ at the end). That's the difference
between the two.
Also, [0-9]\d* can be rewritten as \d+
Karl
"George Durzi" <gd****@hotmail.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl... If I have a regexvalidator in a webform with a validation expression of ^[+]?[0-9]\d* and I put the text 2d in a text box being validated by this validator, the validator fires.
This regex is a simple one that only allows the user to enter integer values.
However, if I do this on the server side like this
Regex rx = new Regex(@"^[+]?[0-9]\d*"); Match mt = rx.Match("2d");
I get success!!!! why?? is there an option I should be setting?
Karl,
Thank you again, that worked perfectly.
And thanks for the regex refining tip :)
"Karl" <none> wrote in message news:OO**************@tk2msftngp13.phx.gbl... I think the regularexpressionvalidator automatically puts ^ at the start
and $ at the end...2d DOES match ^[+]?[0-9]\d* but it DOES NOT match ^[+]?[0-9]\d*$ (note the extra $ at the end). That's the difference between the two.
Also, [0-9]\d* can be rewritten as \d+
Karl
"George Durzi" <gd****@hotmail.com> wrote in message news:%2******************@tk2msftngp13.phx.gbl... If I have a regexvalidator in a webform with a validation expression of ^[+]?[0-9]\d* and I put the text 2d in a text box being validated by
this validator, the validator fires.
This regex is a simple one that only allows the user to enter integer values.
However, if I do this on the server side like this
Regex rx = new Regex(@"^[+]?[0-9]\d*"); Match mt = rx.Match("2d");
I get success!!!! why?? is there an option I should be setting?
George,
Glad you got it working. (Good eyes Karl!)
Just a note: You could also use a CompareValidator instead of the
RegularExpressionValidator. If you leave the CompareValidator's
ControlToCompare property blank and set it's Operator property to
DataTypeCheck you may then set it's Type property to check if a value
entered is a String, Integer, Double, Date, or Currency.
While I love that I can do almost anything with the regular expression
validator I find simple data type checks much easier to set up with the
CompareValidator.
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"George Durzi" <gd****@hotmail.com> wrote in message
news:uJ*************@TK2MSFTNGP10.phx.gbl... Karl, Thank you again, that worked perfectly.
And thanks for the regex refining tip :)
"Karl" <none> wrote in message news:OO**************@tk2msftngp13.phx.gbl... I think the regularexpressionvalidator automatically puts ^ at the start and $ at the end...2d DOES match ^[+]?[0-9]\d* but it DOES NOT match ^[+]?[0-9]\d*$ (note the extra $ at the end). That's the difference between the two.
Also, [0-9]\d* can be rewritten as \d+
Karl
"George Durzi" <gd****@hotmail.com> wrote in message news:%2******************@tk2msftngp13.phx.gbl... > If I have a regexvalidator in a webform with a validation expression of > ^[+]?[0-9]\d* and I put the text 2d in a text box being validated by this > validator, the validator fires. > > This regex is a simple one that only allows the user to enter integer > values. > > However, if I do this on the server side like this > > Regex rx = new Regex(@"^[+]?[0-9]\d*"); > Match mt = rx.Match("2d"); > > I get success!!!! why?? is there an option I should be setting? > >
That is a great tip!!! Thank you much! The regularexpressionvalidators do
seem like a little overkill for simple type checks
"S. Justin Gengo" <sjgengo@aboutfortunate[no-spam].com> wrote in message
news:10*************@corp.supernews.com... George,
Glad you got it working. (Good eyes Karl!)
Just a note: You could also use a CompareValidator instead of the RegularExpressionValidator. If you leave the CompareValidator's ControlToCompare property blank and set it's Operator property to DataTypeCheck you may then set it's Type property to check if a value entered is a String, Integer, Double, Date, or Currency.
While I love that I can do almost anything with the regular expression validator I find simple data type checks much easier to set up with the CompareValidator.
-- Sincerely,
S. Justin Gengo, MCP Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order." Nietzsche "George Durzi" <gd****@hotmail.com> wrote in message news:uJ*************@TK2MSFTNGP10.phx.gbl... Karl, Thank you again, that worked perfectly.
And thanks for the regex refining tip :)
"Karl" <none> wrote in message news:OO**************@tk2msftngp13.phx.gbl... I think the regularexpressionvalidator automatically puts ^ at the
start and $ at the end...2d DOES match ^[+]?[0-9]\d* but it DOES NOT match ^[+]?[0-9]\d*$ (note the extra $ at the end). That's the difference between the two.
Also, [0-9]\d* can be rewritten as \d+
Karl
"George Durzi" <gd****@hotmail.com> wrote in message news:%2******************@tk2msftngp13.phx.gbl... > If I have a regexvalidator in a webform with a validation expression
of > ^[+]?[0-9]\d* and I put the text 2d in a text box being validated by this > validator, the validator fires. > > This regex is a simple one that only allows the user to enter integer > values. > > However, if I do this on the server side like this > > Regex rx = new Regex(@"^[+]?[0-9]\d*"); > Match mt = rx.Match("2d"); > > I get success!!!! why?? is there an option I should be setting? > >
George,
You're welcome. Thanks for the praise. :-)
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"George Durzi" <gd****@hotmail.com> wrote in message
news:Om**************@TK2MSFTNGP10.phx.gbl... That is a great tip!!! Thank you much! The regularexpressionvalidators do seem like a little overkill for simple type checks
"S. Justin Gengo" <sjgengo@aboutfortunate[no-spam].com> wrote in message news:10*************@corp.supernews.com... George,
Glad you got it working. (Good eyes Karl!)
Just a note: You could also use a CompareValidator instead of the RegularExpressionValidator. If you leave the CompareValidator's ControlToCompare property blank and set it's Operator property to DataTypeCheck you may then set it's Type property to check if a value entered is a String, Integer, Double, Date, or Currency.
While I love that I can do almost anything with the regular expression validator I find simple data type checks much easier to set up with the CompareValidator.
-- Sincerely,
S. Justin Gengo, MCP Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order." Nietzsche "George Durzi" <gd****@hotmail.com> wrote in message news:uJ*************@TK2MSFTNGP10.phx.gbl... > Karl, > Thank you again, that worked perfectly. > > And thanks for the regex refining tip :) > > "Karl" <none> wrote in message > news:OO**************@tk2msftngp13.phx.gbl... >> I think the regularexpressionvalidator automatically puts ^ at the start > and >> $ at the end...2d DOES match ^[+]?[0-9]\d* but it DOES NOT match >> ^[+]?[0-9]\d*$ (note the extra $ at the end). That's the difference >> between the two. >> >> Also, [0-9]\d* can be rewritten as \d+ >> >> Karl >> >> "George Durzi" <gd****@hotmail.com> wrote in message >> news:%2******************@tk2msftngp13.phx.gbl... >> > If I have a regexvalidator in a webform with a validation expression of >> > ^[+]?[0-9]\d* and I put the text 2d in a text box being validated by > this >> > validator, the validator fires. >> > >> > This regex is a simple one that only allows the user to enter >> > integer >> > values. >> > >> > However, if I do this on the server side like this >> > >> > Regex rx = new Regex(@"^[+]?[0-9]\d*"); >> > Match mt = rx.Match("2d"); >> > >> > I get success!!!! why?? is there an option I should be setting? >> > >> > >> >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Des Small |
last post by:
I want to use sets and regular expressions to implement some
linguistic ideas. Representing sounds by symbols, and properties
(coronal or velar articulation; voicedness) by sets of symbols with...
|
by: Kenneth McDonald |
last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate
feedback, suggestions, and criticism as I work towards finalizing the
API and feature sets. rex is a module intended to make...
|
by: Buddy |
last post by:
Can someone please show me how to create a regular expression to do the
following
My text is set to
MyColumn{1, 100} Test
I want a regular expression that sets the text to the following...
|
by: Neri |
last post by:
Some document processing program I write has to deal with documents
that have headers and footers that are unnecessary for the main
processing part. Therefore, I'm using a regular expression to go...
|
by: Dimitris Georgakopuolos |
last post by:
Hello,
I have a text file that I load up to a string. The text includes
certain expression like {firstName} or {userName} that I want to match
and then replace with a new expression. However,...
| |
by: Billa |
last post by:
Hi,
I am replaceing a big string using different regular expressions (see
some example at the end of the message). The problem is whenever I
apply a "replace" it makes a new copy of string and I...
|
by: Mike |
last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in
matches. I would like to get what the actual regular expression is.
In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
|
by: Allan Ebdrup |
last post by:
I have a dynamic list of regular expressions, the expressions don't change
very often but they can change. And I have a single string that I want to
match the regular expressions against and find...
|
by: NvrBst |
last post by:
I want to use the .replace() method with the regular expression /^ %VAR
% =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)"
regular expression with "":...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |