我希望实现类似Go语言中的
strings.Fields
功能,它可以获取一行中所有非\t
、空格
和\n
连续字符。例如:this is a \n special \t\t word
将返回
[this, is, a, special, word]
在Rust中是否可能实现这一点?
split
函数只接受显式模式。
例如:
a \t\t\t b \t\t\t\t c
使用
for s in line.split("\t\t\t") {
println!("{}", s);
}
将返回
a
b
\t
c