473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Character Sets

RN1
Assume that a TextBox is validated with the following RegEx (users can
enter any number from 1 to 9 in the TextBox):

<asp:TextBox ID="txt" runat="server"/>
<asp:RegularExpressionValidator ID="regexp" ControlToValidate="txt"
ValidationExpression="[1-9]" runat="server"/>

As expected, any number deom 1 to 9 entered in the TextBox evaluates
to True but if I change the ValidationExpression from [1-9] to [1-10],
then only 1 evaluates to True. The rest (from 2 to 10) evaluate to
False. Why are the numbers from 2 to 10 evaluating to False? Can
someone please explain me this?

Like 1, even 0 evaluates to True when the RegEx is [1-10]. In other
words, 0 & 1 evaluate to True & the rest from 2 to 10 evaluate to
False when the RegEx is [1-10].

An earnest request - PLEASE do not suggest alternate expressions to
validate the TextBox since I know that there are other alternatives.
All I want is to understand the logic behind the working of the RegEx
[1-10] & why it doesn't allow numbers from 2 to 10..

Thanks,

Ron
Jun 27 '08 #1
2 1149
RN1 wrote:
Assume that a TextBox is validated with the following RegEx (users can
enter any number from 1 to 9 in the TextBox):

<asp:TextBox ID="txt" runat="server"/>
<asp:RegularExpressionValidator ID="regexp" ControlToValidate="txt"
ValidationExpression="[1-9]" runat="server"/>

As expected, any number deom 1 to 9 entered in the TextBox evaluates
to True but if I change the ValidationExpression from [1-9] to [1-10],
then only 1 evaluates to True. The rest (from 2 to 10) evaluate to
False. Why are the numbers from 2 to 10 evaluating to False? Can
someone please explain me this?

Like 1, even 0 evaluates to True when the RegEx is [1-10]. In other
words, 0 & 1 evaluate to True & the rest from 2 to 10 evaluate to
False when the RegEx is [1-10].

An earnest request - PLEASE do not suggest alternate expressions to
validate the TextBox since I know that there are other alternatives.
All I want is to understand the logic behind the working of the RegEx
[1-10] & why it doesn't allow numbers from 2 to 10..
Regular expressions don't know about numbers, it simply knows about
characters.
[1-10]
is the range from '1' to '1' plus the character '0' so it is the same as
[01]

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
RN1
On Apr 13, 5:33*pm, Martin Honnen <mahotr...@yahoo.dewrote:
RN1 wrote:
Assume that a TextBox is validated with the following RegEx (users can
enter any number from 1 to 9 in the TextBox):
<asp:TextBox ID="txt" runat="server"/>
<asp:RegularExpressionValidator ID="regexp" ControlToValidate="txt"
ValidationExpression="[1-9]" runat="server"/>
As expected, any number deom 1 to 9 entered in the TextBox evaluates
to True but if I change the ValidationExpression from [1-9] to [1-10],
then only 1 evaluates to True. The rest (from 2 to 10) evaluate to
False. Why are the numbers from 2 to 10 evaluating to False? Can
someone please explain me this?
Like 1, even 0 evaluates to True when the RegEx is [1-10]. In other
words, 0 & 1 evaluate to True & the rest from 2 to 10 evaluate to
False when the RegEx is [1-10].
An earnest request - PLEASE do not suggest alternate expressions to
validate the TextBox since I know that there are other alternatives.
All I want is to understand the logic behind the working of the RegEx
[1-10] & why it doesn't allow numbers from 2 to 10..

Regular expressions don't know about numbers, it simply knows about
characters.
* [1-10]
is the range from '1' to '1' plus the character '0' so it is the same as
* [01]

--

* * * * Martin Honnen --- MVP XML
* * * *http://JavaScript.FAQTs.com/- Hide quoted text -

- Show quoted text -
Thanks, Martin, not only for the prompt response but also for the
precise & simple method of explaining me the logic.

Thanks once again,

Ron
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Thom McGrath | last post by:
I have a text area that people should type in (duh) which will later be displayed for other users via HTML. I've taken care of the HTML aspect in a pretty cool way, but I worry about character sets...
0
by: Thiko | last post by:
Hi According to the official mysql manual: http://www.mysql.com/doc/en/Charset-SHOW-CHARSET.html The syntax to show all available character sets is the SHOW CHARACTER SET command. It takes...
19
by: Ian | last post by:
I'm using the following meta tag with my documents: <meta http-equiv="Content-Type" content= "text/html; charset=us-ascii" /> and yet using character entities like &rsquo; and &mdash; It...
5
by: PEK | last post by:
I need some code that convert a multi-byte string to a Unicode string, and Unicode to multi-byte. I work mostly in Windows and know how to solve it there, but I would like to have some platform...
4
by: siliconmike | last post by:
All I know is that there are 8 bit numbers from 0 to 255 mapped to characters like A, B, C, D and some strange looking ones (like the ones used to make boxes in old PC text modes) all these being...
1
by: Vishal | last post by:
Hello! My client has a need to be able to store Japanese characters in their PeopleSoft database. So we need to change the character set from from Latin1_General (1252) to Japanese character set...
37
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
21
by: aegis | last post by:
7.4#1 states The header <ctype.h> declares several functions useful for classifying and mapping characters.166) In all cases the argument is an int, the value of which shall be representable as an...
9
by: jraul | last post by:
1) Am I correct that C++ does not have a defined character set? In particular, a platform might not use the ASCII character set? 2) C++ supports wchar_t types. But again, this has no defined...
0
by: peridian | last post by:
Hi, Can I do a bulk "find and replace" on data in SQL Server to convert character set data? I have data coming in from multiple external sources. That data is not always in UTF-8 or ASCII...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
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...
0
agi2029
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.