My goal is to extract names and numbers from a string in java. Examples: input -> output
1234 -> numbers: [1234], names: []
1234,34,234 -> numbers: [1234, 34, 234], names: []
12,foo,123 -> numbers: [12, 123], names: [foo]
foo3,1234,4bar,12,12foo34 -> numbers: [1234, 12], names: [foo3, 4bar, 12foo34]
foo,bar -> -> numbers: [], names: [foo, bar]
I came up with [^,]+(,?!,+)*
which match all parts of the string, but i dont know how to match only numbers or names (names can contain number - as in example).
Thanks