By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,956 Members | 1,657 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,956 IT Pros & Developers. It's quick & easy.

regex help

P: n/a
In my program, I need a regx that says the format can be
Numeric only with this pattern: 1,3,56,8 or 2
In other words, if there's just one number it passes. However, if there are
2 or more they must be separated by a comma.

Basically (I know this doesn't work)
[0-9] or ([0-9], AND ^[a-zA-Z] {1,5}

TIA
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 2004-12-29, Raven <ra*********@NOSPAMravenphpscripts.com> wrote:
In my program, I need a regx that says the format can be
Numeric only with this pattern: 1,3,56,8 or 2
In other words, if there's just one number it passes. However, if there are
2 or more they must be separated by a comma.

Basically (I know this doesn't work)
[0-9] or ([0-9], AND ^[a-zA-Z] {1,5}


If you want to match one or more numbers separated by commas, try this:

^[0-9]+(,[0-9]+)*$

Regards
Matthias
Jul 17 '05 #2

P: n/a
"Matthias Czapla" <la*@dexato.mine.nu> wrote in message
news:cq*************@news.t-online.com...
On 2004-12-29, Raven <ra*********@NOSPAMravenphpscripts.com> wrote:
In my program, I need a regx that says the format can be
Numeric only with this pattern: 1,3,56,8 or 2
In other words, if there's just one number it passes. However, if there
are
2 or more they must be separated by a comma.

Basically (I know this doesn't work)
[0-9] or ([0-9], AND ^[a-zA-Z] {1,5}


If you want to match one or more numbers separated by commas, try this:

^[0-9]+(,[0-9]+)*$

Regards
Matthias


Thank you so much!
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.