ruby:将字符串转换为字符数组(范例)
凉爽拍拍
・1 分钟阅读
"This is the bee's knees".scan/w/
#=> ["T", "h", "i", "s", "i", "s", "t", "h", "e", "b", "e", "e", "s", "k", "n", "e", "e", "s"]
字符串#scan将查找与模式匹配的任何内容,并将它返回数组。