String pattern matching, what is the result of executing the following code? And the reasons.

related codes

var colorText = "red,blue,green,yellow";
colorText.split(/[^\,]+/);
// ["", ",", ",", ",", ""]
Jul.06,2022

regularly matches non-comma content. Split uses the matching content as a knife to cut the string into two halves


there is actually an empty string before red. Similarly, there is an empty string
after yellow, and your regular character is separated by characters other than comma [1,], so three commas plus two empty strings

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e49a35-65366.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e49a35-65366.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?