regex - RegExp in Javascript String Split method -


the following javascript code snippet famous javascript book nicholas c. zakas:

var colortext = “red,blue,green,yellow”; var colors1 = colortext.split(“,”); //[“red”, “blue”, “green”, “yellow”] var colors2 = colortext.split(/[^\,]+/); //[“”, “,”, “,”, “,”, “”] 

it quite difficult understand how second split works.

can explain it?

javascript split based on delimeter give. if give "," omit "," string , give between string characters array.

in regex case choosing expect "," it's omits other characters , 4 "," array


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -