Java Script Regex - Find if only allowed characters are in the script
I am trying to write a Java Script regex to match if a string contains only allowed characters in following manner -

1. String shall have only 0, 1, x or comma (,) in it.
2. Each number (0, 1 or "x") shall be separated by a comma (,)
3. There shall be at least one comma separated value (i.e. "0,1" or "0,x,1")
4. The comma shall always be surrounded by numbers or "x" (i.e. "," or ",0" is invalid )

Is it possible to write a regex for this condition? I am able to do it using java script string split but that does not appear elegant to me. Hope someone could help come up with a regex for above condition.
Java Script Regex - Find if only allowed characters are in the script
===

I am trying to write a Java Script regex to match if a string contains only allowed characters in following manner -

1. String shall have only 0, 1, x or comma (,) in it.
2. Each number (0, 1 or "x") shall be separated by a comma (,)
3. There shall be at least one comma separated value (i.e. "0,1" or "0,x,1")
4. The comma shall always be surrounded by numbers or "x" (i.e. "," or ",0" is invalid )

Is it possible to write a regex for this condition? I am able to do it using java script string split but that does not appear elegant to me. Hope someone could help come up with a regex for above condition.