The string can contain any number of any characters in any order. However, it should not contain both comma and dash simultaneously. Examples:
123 // ok
1,23 // ok
1-23 // ok
1,2-3 // not ok
1-2-3 // ok
foobar! // ok
a---t // ok
,3,*, // ok
k-, // not ok
2
Answers
It looks like for searching a group with comma or dash and repeating of this group or not.
Regex: