新手问题 p " a\t b\n c".split (/\s+/) 中 +号的作用

chenyanlin_1983 · May 11, 2017 · Last by chenyanlin_1983 replied at May 11, 2017 · 1131 hits
p " a\t b\n c".split(/\s/)=====["", "a", "", "b", "", "c"]
p " a\t b\n c".split(/\s+/)====["", "a", "b", "c"]

请问 + 号的作用只是匹配第一个空字符串?

是匹配一个或多个连续空字符的意思

Reply to wootaw

有 + 号就是匹配一个 没 + 号就是匹配多个咯,3Q

反了,你的理解

Reply to wootaw

p"1,2,,3,4,,".split(',',-4),请问下这个负号代表啥意思呢

了解了 正无穷

You need to Sign in before reply, if you don't have an account, please Sign up first.