给定一个输入字符串" word1 word2 word3 word4 ",如何将最佳方法拆分为Go中的字符串数组?请注意,每个单词之间可以有任意数量的空格或unicode-spacing字符.
" word1 word2 word3 word4 "
在Java中我会使用someString.trim().split("\\s+").
someString.trim().split("\\s+")
(注意:在Go中使用正则表达式可能重复的Split字符串不能提供任何高质量的答案.请提供一个实际示例,而不仅仅是指向regexp或strings包引用的链接.)
regexp
strings
regex go
go ×1
regex ×1