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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -