tr1::regex を使用して、文字列からいくつかの一致を抽出しようとしています。文字列の例は次のとおりです。
asdf werq "one two three" asdf
そして、私はそれから抜け出したいです:
asdf
werq
one two three
asdf
引用符で囲まれたものがグループ化されているので、正規表現を使用しようとしています\"(.+?)\"|([^\\s]+)
。私が使用しているコードは次のとおりです。
cmatch res;
regex reg("\"(.+?)\"|([^\\s]+)", regex_constants::icase);
regex_search("asdf werq \"one two three\" asdf", res, reg);
cout << res.size() << endl;
for (unsigned int i = 0; i < res.size(); ++k) {
cout << res[i] << endl;
}
しかし、それは出力します
3
asdf
asdf
私は何を間違っていますか?