|
-
Apr 23rd, 2010, 06:05 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Validate empty string in regular expression
Hello,
I have a string field where the user only can enter NULL or the nummeric value 1-199
I know
^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-9][0-9]|4[0-9][0-9]|5[0-9][0-9]|6[0-9][0-9]|7[0-9][0-9]|8[0-9][0-9]|9[0-9][0-9])$
Checks for the value 0 to 199 but not null.
How can I change the formula so When Null or 1 to 199 is entered results in a match?
-
Apr 23rd, 2010, 06:09 AM
#2
Re: Validate empty string in regular expression
^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9][0-9]|3[0-9][0-9]|4[0-9][0-9]|5[0-9][0-9]|6[0-9][0-9]|7[0-9][0-9]|8[0-9][0-9]|9[0-9][0-9])?$
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Apr 23rd, 2010, 07:07 AM
#3
Thread Starter
Fanatic Member
Re: Validate empty string in regular expression
That's it..
Thank you very much!!!!!
-
Apr 23rd, 2010, 07:19 AM
#4
Thread Starter
Fanatic Member
Re: [RESOLVED] Validate empty string in regular expression
One small question?
What when I want to match for empty spaces?
-
Apr 23rd, 2010, 07:21 AM
#5
Re: [RESOLVED] Validate empty string in regular expression
\s is the regex symbol for white space (space, v-tab... etc) You can check out regex lib for samples and details
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
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
|