我在 Ubuntu 14.04 上使用 Qt 4.8。
我目前正在尝试移植一个 Windows 应用程序...作者在应用程序代码中大量使用了 boost。
我已经用 Qt 等效结构替换了许多 boost 调用(我对 boost 的经验为零)。
现在我偶然发现了这个:
string command;
...
boost::char_separator<char> sep(",\t\r ");
boost::tokenizer<boost::char_separator<char>> tokens(command, sep);
有 Qt 的等价物吗?
我试过了:
QStringList tokens = QString(command.data()).split(QRegExp("\\s+"));
但是好像不太好...
1) 首先:它的行为不像原始应用程序。
2)第二:我总是得到一个空 token 。很奇怪,我不知道为什么...!?!
为了解决这些问题,你能给我一些帮助或分享一些想法吗?
预先感谢您的时间和耐心等待。
最佳答案
如问题评论中所述,解决方案是使用:
split(QRegExp("[,\t\r ]"), QString::SkipEmptyParts)
关于c++ - 相当于 boost 分词器表达式/构造的 Qt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41614774/