用空格分隔文本 [英] Split text by whitespaces
本文介绍了用空格分隔文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些文本文件,有一些文本信息,我需要拆分这个文本的空格和所有的字推到列表。
I have text file with some text information and i need to split this text at spaces and all word push into List.
我这样做:
QStringList list = line.split(" ");
for (int i = 0; i < list.count(); i++){
table.push_back(list[i]);
this->ui->textEdit->setText(list[i]);
}
行中有我的文字。但是当我测试这个代码,我得到所有的文本,但不是由字。
In line i have my text. But when i test this code i get all text, but not by the word.
谢谢你。
推荐答案
尝试:
line.split(QRegExp("\\s"));
这篇关于用空格分隔文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文