アプリケーションに「110110」を入力すると、2番目のチャンクが「2」を出力し、 。sregex_iteratorを正規表現の可変パターンと組み立てたパターンで使用しているときに2つの異なる結果が出る理由
結果が異なるのはなぜですか?
どのように関数呼び出しで正規表現パターンを構築できますか?
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
auto begin = sregex_iterator(s.begin(),s.end(),regex{R"(110)"});
auto end = sregex_iterator();
cout << distance(begin,end) << endl;
const regex r(R"(110)");
begin = sregex_iterator(s.begin(),s.end(),r);
end = sregex_iterator();
cout << distance(begin,end) << endl;
}
[this]に関連していることを確かめてください(http://stackoverflow.com/questions/33154890/simple-stdregex-search-code-wont- compile-with-apple-clang-std-c14) – NathanOliver
はい、ビット/ stdC++。h ... compsのクイックタイピングコードの悪い習慣。 iostreamとregexの置き換えは自由に行えます:) – forrest