I\'m trying to split a string using either commas or whitespace. A comma can optionally be preceded and/or followed by whitespace, and whitespace by itself also counts as a
With regexes the capture expression (x) remembers the match (and possibly returns that to the String.split). You should use the (non-capturing) grouping expression (?:x). See e.g. the Mozilla Docs on RegExp for more.