Boost或STL中是否有替代QStringList的替代方法。我想要实现的是分裂路径,例如。 dvb://1.2.3.4/launchpad/dyn/index.htm可以在QString List中完成单独的字符串分离:
QStringList path = objectPath.split(QChar('/'), QString::SkipEmptyParts);
谢谢。
答案 0 :(得分:1)
boost::split
可以根据一个或多个分隔符将字符串拆分为std::vector<std::string>
:
#include <vector>
#include <string>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
std::vector<std::string> path_parts;
std::string s("some/file/path");
boost::split(path_parts, s, boost::is_any_of("/"));