quick help needed on regular expression validator

D

David Cho

I am looking to use the input in the text box in the IN SQL clause (for
example, "WHERE studentID in (233, 3422, 43232)")

So I need the validator to validate

number, number, number, number

So acceptable
343435, 2232, 333, 3434

Not acceptable
- ,343,3434,3434, (nos comma before the string and after)
- r54, e3233 (alphas mixed in)
- 3232|12121|2232 (wrong delimiter)

Thank you very much. I plan on studying regular expressions soon, but
this is pretty urgent.
 
W

Wilco Bauwer

Try something like: "\(\d+(,\s*\d+)*\)"

Basically it means:
- Match a literal '('
- Match a digit (\d), once or more (+)
- Match a comma, 0 or more (*) spaces followed by at least (+) 1 digit
(\d) - Match this 0 or more times.
- Match a literal ')'

HTH.
 
J

John Timney \(ASP.NET MVP\)

343435, 2232, 333, 3434

Not being very good at them myself I'll take a guess
at.........."[0-9],[0-9],[0-9],[0-9]" - which should give you four numeric
ranges from 0 through 9 seprated by commasor being very specific
...........(another guess)...........individual pattern of specific digits

"\d\d\d\d\d\d,\d\d\d\d,\d\d\d,\d\d\d";

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
D

David Cho

I would like to get it to work without the beggning and ending
paranthesis. I can't figure it out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top