BOOST.REGEX定界器解析
Boost.Regex delimiter parsing
这是一个快速的问题,我只是在Boost文档中找不到它或任何其他Boost Regex示例/教程。
假设我想使用此实现来将字符串归为字符串:
boost::regex re("[\sXY]+");
std::string s;
while (std::getline(std::cin, s)) {
boost::sregex_token_iterator i(s.begin(), s.end(), re, -1);
boost::sregex_token_iterator j;
while (i != j) {
std::cout << *i++ << " ";
}
std::cout << std::endl;
}
问题在于,定界符表达式不会迭代。我还需要定界符字符串。我该如何确保?
如果我正确理解,除了通过令牌迭代之外,还要通过定义器迭代。创建另一个值得确定的令牌的令牌迭代器是否足够?
boost::sregex_token_iterator i(s.begin(), s.end(), re, -1);
boost::sregex_token_iterator j;
//now find the tokens that match the regex -> the delimiters
boost::sregex_token_iterator begin(s.begin(), s.end(), re), end;
while (i != j)
{
std::cout << *i++ << " ";
if( begin != end)
{
std::cout << "(delimiter = " << *begin++ << ") ";
}
}
相关文章:
- 使用 boost::regex 从目录中获取带有一些正则表达式的文件名称时出现意外输出
- 在VC2015U3上,std::regex比boost::regex慢得多
- 使用 boost::regex (c++) 比较两个正则表达式
- Build Boost Regex for Windows VS2013
- std::string references、std::regex和boost::filesystem的基本概念
- boost::regex 和std::regex之间的不一致?
- 尝试使用生成文件编译程序时"fatal error: boost/regex.hpp: No such file or directory" C++
- 使用Boost或Regex拆分这条线
- 带有Boost Regex库的未解决的外部对象
- Byte Regex与C 的Boost匹配
- boost::regex链接问题在Xcode 4.5.2中
- 如何检查使用哪个匹配组进行匹配(boost-regex)
- boost::regex和std::regex之间的不一致
- Boost.Regex parsing
- BOOST.REGEX定界器解析
- 以下等级表达式不适合Boost Regex
- C++, TR1, Regex and Boost
- 在Windows C 代码:: Blocks上的Boost Regex
- Boost Regex用于格式化MAC地址字符串
- Regex boost library comparing