Hi everyone. I have never worked with regular expressions
before and here is my dillema:
I have a textbox that I want to only accept this type of
input:
1,2,3-8,10,16 ( Comma separated numbers or Hyphenated
ranges )
I want to use a validator for this, so I assume I use a
regularexpressionvalidator?? If so any help on what I
would write for a regular expression?? Thank you
Jorell 3 4056
Well, you can interrogate it on a number of levels - it really depends on
how thoroughly you want to make your validation.
I mean, you could validate the characters themselves:
^[0-9\-,]*$
What this means: you will have zero or more of the characters 0 through 9, a
dash, or a comma. This would filter out any other character, however, you
would then approve the string ,-,,-,,-9-,,
If you want to get a little bit closer, here is a better regex:
^([0-9]+(\-[0-9]+)*,*)+$
Now, you are required to have one or more numbers, followed by zero or more
instances of a dash followed by one or more numbers, followed by zero or
more instances of a comma - this entire sequence being repeated one or more
times.
Now, you will match 1,2-9,13. You also guarantee that you will get at least
one number put in. However, this doesn't prevent you from putting in 9-2,
which may throw your parser off. It will also validate 0-2-4.
So, you have to sit and play with exactly what you will allow, and gradually
keep expanding what you are doing until you have a great validation in place
that covers every instance that you can come up with.
If your parser is very particular about how the input comes in, then you may
want to write a custom validator in code.
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
"Jorell" <zw******@nospam.powervisionsw.com> wrote in message
news:02****************************@phx.gbl... Hi everyone. I have never worked with regular expressions before and here is my dillema:
I have a textbox that I want to only accept this type of input:
1,2,3-8,10,16 ( Comma separated numbers or Hyphenated ranges )
I want to use a validator for this, so I assume I use a regularexpressionvalidator?? If so any help on what I would write for a regular expression?? Thank you
Jorell
Thank you very much!!! Do you happen to know where a
person can learn a little more about creating those??
Thanks in advance!!
Jorell -----Original Message----- Well, you can interrogate it on a number of levels - it
really depends onhow thoroughly you want to make your validation.
I mean, you could validate the characters themselves:
^[0-9\-,]*$
What this means: you will have zero or more of the
characters 0 through 9, adash, or a comma. This would filter out any other
character, however, youwould then approve the string ,-,,-,,-9-,,
If you want to get a little bit closer, here is a better
regex: ^([0-9]+(\-[0-9]+)*,*)+$
Now, you are required to have one or more numbers,
followed by zero or moreinstances of a dash followed by one or more numbers,
followed by zero ormore instances of a comma - this entire sequence being
repeated one or moretimes.
Now, you will match 1,2-9,13. You also guarantee that you
will get at leastone number put in. However, this doesn't prevent you from
putting in 9-2,which may throw your parser off. It will also validate 0-
2-4. So, you have to sit and play with exactly what you will
allow, and graduallykeep expanding what you are doing until you have a great
validation in placethat covers every instance that you can come up with.
If your parser is very particular about how the input
comes in, then you maywant to write a custom validator in code.
-- Chris Jackson Software Engineer Microsoft MVP - Windows XP Windows XP Associate Expert -- "Jorell" <zw******@nospam.powervisionsw.com> wrote in
messagenews:02****************************@phx.gbl... Hi everyone. I have never worked with regular
expressions before and here is my dillema:
I have a textbox that I want to only accept this type of input:
1,2,3-8,10,16 ( Comma separated numbers or Hyphenated ranges )
I want to use a validator for this, so I assume I use a regularexpressionvalidator?? If so any help on what I would write for a regular expression?? Thank you
Jorell
.
Here are a couple articles to help you get going.
Look closely at the EvaluationFunction attribute and the EvaluateIsValid
method (or function) http://www.codeproject.com/useritems/DateValidator.asp http://www.c-sharpcorner.com/Code/20...mValidator.asp
HTH,
bill
"Jorell" <zw******@nospam.powervisionsw.com> wrote in message
news:02****************************@phx.gbl... Thank you very much!!! Do you happen to know where a person can learn a little more about creating those?? Thanks in advance!!
Jorell
-----Original Message----- Well, you can interrogate it on a number of levels - it really depends onhow thoroughly you want to make your validation.
I mean, you could validate the characters themselves:
^[0-9\-,]*$
What this means: you will have zero or more of the characters 0 through 9, adash, or a comma. This would filter out any other character, however, youwould then approve the string ,-,,-,,-9-,,
If you want to get a little bit closer, here is a better regex: ^([0-9]+(\-[0-9]+)*,*)+$
Now, you are required to have one or more numbers,
followed by zero or moreinstances of a dash followed by one or more numbers, followed by zero ormore instances of a comma - this entire sequence being repeated one or moretimes.
Now, you will match 1,2-9,13. You also guarantee that you will get at leastone number put in. However, this doesn't prevent you from putting in 9-2,which may throw your parser off. It will also validate 0- 2-4. So, you have to sit and play with exactly what you will
allow, and graduallykeep expanding what you are doing until you have a great validation in placethat covers every instance that you can come up with.
If your parser is very particular about how the input comes in, then you maywant to write a custom validator in code.
-- Chris Jackson Software Engineer Microsoft MVP - Windows XP Windows XP Associate Expert -- "Jorell" <zw******@nospam.powervisionsw.com> wrote in messagenews:02****************************@phx.gbl... Hi everyone. I have never worked with regular expressions before and here is my dillema:
I have a textbox that I want to only accept this type of input:
1,2,3-8,10,16 ( Comma separated numbers or Hyphenated ranges )
I want to use a validator for this, so I assume I use a regularexpressionvalidator?? If so any help on what I would write for a regular expression?? Thank you
Jorell
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bradley Plett |
last post by:
I'm hopeless at regular expressions (I just don't use them often
enough to gain/maintain knowledge), but I need one now and am looking
for help. I need to parse through a document to find a URL,...
|
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: Lee Kuhn |
last post by:
I am trying the create a regular expression that will essentially match
characters in the middle of a fixed-length string. The string may be any
characters, but will always be the same length. In...
|
by: James D. Marshall |
last post by:
The issue at hand, I believe is my comprehension of using regular
expression, specially to assist in replacing the expression with other text.
using regular expression (\s*) my understanding is...
|
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: Pete Davis |
last post by:
I'm using regular expressions to extract some data and some links from some
web pages. I download the page and then I want to get a list of certain
links.
For building regular expressions, I use...
|
by: Zach |
last post by:
Hello,
Please forgive if this is not the most appropriate newsgroup for this
question. Unfortunately I didn't find a newsgroup specific to regular
expressions.
I have the following regular...
|
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: Mr.Steskal |
last post by:
Posted: Wed Jul 11, 2007 7:01 am Post subject: Regular Expression
Help
--------------------------------------------------------------------------------
I need help writing a regular...
|
by: Lit |
last post by:
Hi,
I am looking for a Regular expression for a password for my RegExp
ValidationControl
Requirements are,
At least 8 characters long.
At least one digit
At least one upper case character
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |