案例一(尾随空间)
> "on behalf of all of us ".split(/\W+/)
=> ["on", "behalf", "of", "all", "of", "us"]
但是如果有前导空格,那么它会给出以下内容
案例2(领先空间)
> " on behalf of all of us".split(/\W+/)
=> ["", "on", "behalf", "of", "all", "of", "us"]
我也期待案例 2 的案例 1 的结果。
添加
> "@dhh congratulations!!".split(/\W+/)
=> ["", "dhh", "congratulations"]
有人可以帮我理解这种行为吗?