我使用Boost来匹配字符串中的子串.Io迭代结果,我需要使用regex_iterator().
这是我找到的唯一用法示例,但我不理解回调.有人可以给我一个功能的例子吗?
让我们假设我的输入文本是:
"Hello everybody this is a sentense
Bla bla 14 .. yes
date 04/15/1986
"
Run Code Online (Sandbox Code Playgroud)
我想得到:
"Hello" "everybody" "this" "is" "a" "sentense" "bla" "yes" "date"
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Boost正则表达式来查看其中是否有某个整数.
此页面上的一个示例是
bool validate_card_format(const std::string& s)
{
static const boost::regex e("(\\d{4}[- ]){3}\\d{4}");
return regex_match(s, e);
}
Run Code Online (Sandbox Code Playgroud)
还有一个可能是工作示例这里.
但是当我在我的机器上尝试它时,我得到五页不可读的错误.这是怎么回事?
#include <boost/regex.hpp>
#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
static const boost::regex rxInt("[0-9]+");
string word = "foobar";
if(boost::regex_match(word, rxInt)) {
cout << "Integer" << endl;
} else {
cout << "Not integer" << endl;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
$ g ++ test.cpp的错误.是否有一些理智的方式来解决这里发生的事情?
/tmp/ccRNnDit.o: In function `bool boost::regex_match<__gnu_cxx::__normal_iterator<char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, …Run Code Online (Sandbox Code Playgroud)