Regex to accept comma and new line as optional for a input value

My input can accept comma-separated integer values with new line for each value as optional

Example:
option 1:

123,
456,
345

or option 2

123,234,456

or option 3

123,
234,
456,789 

both should be valid.

I have tried validating with regex '/^d+(,nd+)*$/,', this work for option1 in above example but fails for second and third.

help me to change this regex to fit in all the option.