Kumar
Kumar

Reputation: 193

regular expression for comma separated Numeric values

can you please help me to write a regular expression where it allows comma separated Numeric values. Below is the Expression that i have tried.

Expression : /^[0-9,]+$/

Test String : 123,111 --> Shows as Match --> Correct

Test String : 123,111, -- > Shows as Match --> Incorrect --> if comma is specified it should follow with number

Upvotes: 1

Views: 541

Answers (1)

vks
vks

Reputation: 67998

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

You can construct it this way.

Upvotes: 2

Related Questions