【发布时间】:2011-07-04 06:48:53
【问题描述】:
我不确定如何使用boost::is_any_of 使用一组字符拆分字符串,其中任何一个字符都应该拆分字符串。
我想做这样的事情,因为我理解 is_any_of 函数需要一个 Set 参数。
std::string s_line = line = "Please, split|this string";
std::set<std::string> delims;
delims.insert("\t");
delims.insert(",");
delims.insert("|");
std::vector<std::string> line_parts;
boost::split ( line_parts, s_line, boost::is_any_of(delims));
但是,这会产生一个 boost/STD 错误列表。
我应该坚持使用is_any_of 还是有更好的方法来做到这一点,例如。使用正则表达式拆分?
【问题讨论】:
-
很遗憾
is_any_of没有使用迭代器范围。