我有一个由逗号分隔的值组成的字符串;此字符串还包含全名(firstName,lastName)。我需要创建一个包含字符串中所有值的数组,但也需要包含全名(不分割)。我怎么能避免分割全名?谢谢!
var string = "Joe, Doe,Author,Title,Mary, Doe",
array = string.split(",");
结果:
["Joe", " Doe", "Author", "Title", "Mary", " Doe"]
但我需要:
["Joe, Doe", "Author", "Title", "Mary, Doe"]
答案 0 :(得分:2)
{{1}}
结果:" Joe,Doe" "作者" "名称" " Mary,Doe",假设名称中总是有空格而不是其他文本。