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
Post a Comment