I have a regular expression /\s*,\s*/ that matches left spaces followed by comma then right spaces.
Example:
var str = "john,walker james , paul";
var arr = str.split(/\s*,\s*/);
Values in arr = [john,walker james,paul] // Size: 3
Example with Chinese characters:
var str = "继续,取消 继续 ,取消";
var arr = str.split(/\s*,\s*/);
Values in arr = ["继续,取消 继续 ,取消"] // Size: 1, All values at index 0 no splitting happened
Tried splitting characters with unicodes:
var str = "john,walker james , paul";
var arr = str.split(/\u0020*\u002C\u0020*/);
Values in arr = [john,walker james,paul] // Size: 3
var str = "继续,取消 继续 ,取消";
var arr= str.split(/\u0020*\u002C\u0020*/);
Values in arr = ["继续,取消 继续 ,取消"] // Size: 1, All values at index 0 no splitting happened
I went through this link but not much info was there that I can use in my scenario. Is it really impossible to create regex for Chinese characters and split them?