|
-
Dec 13th, 2005, 05:26 PM
#1
[RESOLVED] RegEx Question
(([0])?[1-9])|[1][0-2]
This will allow any digit 1 through 9 and also allow it to lead with a zero. I run into a problem when I try to do 10, 11 and 12. Those cases are the ones I specified right of the alteration character (atleast, I thought?).
What am I doing wrong, why doesn't that match? Since it's an alteration, I figured it would work just like an "or" and ignore everything on the left. Am I missing something obvious? 
Edit:
I just tried:
(([0])?[1-9])|1[0-2]
Same problem...
-
Dec 14th, 2005, 08:31 AM
#2
Re: RegEx Question
The expression I'm using now is:
((0)?[1-9])|(1[0-2])
((0)?[1-9]) will validate 1-9 with an optional leading zero
(1[0-2]) will validate 10-12
When I use the full expression with |, it only validates the left half.
The alteration is deffinitely the problem. Anyone know what I'm doing wrong?
Edit: I tested the two halves, they work individually.
-
Dec 14th, 2005, 09:03 AM
#3
Re: RegEx Question
Ok, someone's gotta know what I'm doing wrong. 
Rep points avaliable as always, please help me out.
-
Dec 14th, 2005, 09:26 AM
#4
Re: RegEx Question
*throws hands up in the air*
Ok, I give up. I'll just do a nasty run-on validation function instead of any client-side validation. I'm running out of time.
Thanks anyway.
-
Dec 14th, 2005, 10:13 AM
#5
Re: RegEx Question
try this
(^0?[1-9]$)|(^1[0-2]$)
-
Dec 14th, 2005, 10:33 AM
#6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|