Regex to match comma separated list with no comma on the end

.net, c#, regex

Solution

Try using this pattern:

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

You can test it here.

Problem

I need a .Net (C#) Regex to match a comma separated list of numbers that will not match if there is a comma as the last character ``` 123,123,123,123 true - correct match 123,123,123,123, false - comma on end 123,123,123,,123 false - double comma ,123,123,123,123 false - comma at start "" false - empty string 123 true - single value ``` I have found this Regex but matches when there is a comma on the end `^([0-9]+,?)+$` What would be a Regex pattern that would fit this pattern? EDIT: Added 1 example for clarity the correct answer works for `123`

Original source