473,881 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex validation problem

([1-2]{0,1}[1-9]{1})|([3]{1}[0-2]{1})

I am trying to validate for numbers between 1-32 which is the valid
range using the above regex in a asp:regexpvalid ator. However it
accepts numbers 1-29 correctly but does not accept 30-32 (this is meant
to be handled by the part of the regex after the pipe | char).

Does anyone know why this does not work?

Rasika.

PS. I am unable to use the range validator in this situation.

Jun 26 '06 #1
3 1254
Hi.

mmm, if I were you, I'd probably use this RegEx:
([1-32]{1,})

(It takes the greatest number from 1 to 32: if you write 12 it takes 12 and
not only 1.)

Does it work for you?

Lorenzo
"Rasika WIJAYARATNE" <ra*****@gmail. com> ha scritto nel messaggio
news:11******** *************@i 40g2000cwc.goog legroups.com...
([1-2]{0,1}[1-9]{1})|([3]{1}[0-2]{1})

I am trying to validate for numbers between 1-32 which is the valid
range using the above regex in a asp:regexpvalid ator. However it
accepts numbers 1-29 correctly but does not accept 30-32 (this is meant
to be handled by the part of the regex after the pipe | char).

Does anyone know why this does not work?

Rasika.

PS. I am unable to use the range validator in this situation.

Jun 26 '06 #2
> Hi.

mmm, if I were you, I'd probably use this RegEx:
([1-32]{1,})

(It takes the greatest number from 1 to 32: if you write 12 it takes 12 and
not only 1.)


No, it doesn't. Regex knows nothing about numbers, it only knows about
characters. This regex means:
characters from '1' to '3', plus '2', repeated one or more times.
It does match "12", it also should match "112", but it doesn't match
"29".

Hans Kesting
Jun 26 '06 #3
> ([1-2]{0,1}[1-9]{1})|([3]{1}[0-2]{1})

I am trying to validate for numbers between 1-32 which is the valid
range using the above regex in a asp:regexpvalid ator. However it
accepts numbers 1-29 correctly but does not accept 30-32 (this is meant
to be handled by the part of the regex after the pipe | char).

Does anyone know why this does not work?

Rasika.

PS. I am unable to use the range validator in this situation.


Switch the parts around:
([3]{1}[0-2]{1}) | ([1-2]{0,1}[1-9]{1})
(spaces added for clarity)

Hans Kesting
Jun 26 '06 #4

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

Similar topics

3
2421
by: Alan Pretre | last post by:
Can anyone help me figure out a regex pattern for the following input example: xxx:a=b,c=d,yyy:e=f,zzz:www:g=h,i=j,l=m I would want four matches from this: 1. xxx a=b,c=d 2. yyy e=f 3. zzz (empty) 4. www g=h,i=j,l=m
1
1730
by: Colin Reid | last post by:
Hey MS, here's an apparent problem in the base class library. I pulled the email validation pattern "^((*)*@(()+(*)*\.)+{2,9})" from http://regexlib.com. If I validate the email address "test@someverylongemailaddress.com" against it by just creating a RegEx and calling IsMatch it works fine, but if I create a schema defining a simple type restricting an xs:string by the regex pattern, it takes over full minute at 100% cpu to match....
2
1856
by: Jan | last post by:
Hi all, I have got the following problem: User fills in excel sheet, this is loaded in Acces. After this I run a validation tool to validate the field formats. One fields is allowed to be null, empty (length = 0) and max 30 chars. I use the following expression: ^.{0,30}\b It seems that this is not working as I would expect when fields are empty or
3
1956
by: Mike | last post by:
I'm trying to have a form where a user has to enter a valid email address, and I'm trying to use the RegEx Validation control to do that. The problem is that when a user submits the form with a blank line, it is ACCEPTED even though it does not pass the pattern match in the expression. Another problem is that if there are leading spaces or trailing in a valid email address, the expression fails. Case 1:(blank) : ...
2
1585
by: Hailstorm | last post by:
How can I control if "a textbox is empty or not" with regex validation? I don't want to use required field validator because I have a masked textbox control and it has "ValidationExpress" property. For example, if I want to control if it's a time value, I use "(()|())()" but it doesn't work when textbox is empty. How can I solve this problem? I want user to fill this area. And by the way, if I try to use a req field validator for this, my...
4
1368
by: | last post by:
Here is an interesting one. Running asp.net 2.0 beta 2. I have a regular expression used in a regex validator that works on the client side in Firefox but not in IE. Any ideas? IE always reports the field is invalid. The expression is: ^(?!\d)(?=.*\d)(?=.*)(?=.*)(?=.*).{8,25}$ If I enter "Test_Field1" Firefox considers it valid on client side, IE doesnt. Server side considers it valid too because when I submit the form in
3
3994
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having a couple of problems, which I'll try to describe. But this e-mail will only reproduce one of them, in a "short" example. What I'm generally doing is having each form entry contained in a div, which as a label, an input with some event handlers,...
1
1958
by: Jim Dornbush | last post by:
Has anyone seen an updated regex expression from Microsoft for the email validation expression so that single quotes are allowed? I've been using the canned regex for emails, but recently been informed by a customer that the single quote is allowed as part of the email address (Mr. O'Leary). I prefer using the un-modified version from the framework, but will update my local code regardless.
7
1691
by: MattMika | last post by:
Can anyone point out the problem with this? The commented regex var and if statement dont work and break the GroupName check when uncommented. I tested the AccessCodeRegxp with preg_match and it seems to work fine, it just wont here. Any pointers would be great. <script language="javascript"><!-- function check_form() { var error = 0; var error_message = "<?php echo JS_ERROR; ?>"; var customers_group_name =
10
1893
by: bullockbefriending bard | last post by:
first, regex part: I am new to regexes and have come up with the following expression: ((1|),(1|)/){5}(1|),(1|) to exactly match strings which look like this: 1,2/3,4/5,6/7,8/9,10/11,12 i.e. 6 comma-delimited pairs of integer numbers separated by the
0
9775
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10715
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10396
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9550
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7952
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7105
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5780
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5974
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3221
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.