1
"!"で始まるすべての10進数をどのように一致させるのですか?指定された文字列の中で(bang)?私は、次のコードを書かれているが、それはアサート'!'で始まる10進数のマッチング方法C++で
#include<iostream>
#include<regex>
int main()
{
std::string s1("{!112,2,3}");
std::regex e(R"(\!\d+)", std::regex::grep);
std::cout << s1 << std::endl;
std::sregex_iterator iter(s1.begin(), s1.end(), e);
std::sregex_iterator end;
while(iter != end)
{
std::cout << "size: " << iter->size() << std::endl;
for(unsigned i = 0; i < iter->size(); ++i)
{
std::cout << "the " << i + 1 << "th match" << ": " << (*iter)[i] << std::endl;
}
++iter;
}
}
アサート
terminate called after throwing an instance of 'std::regex_error'
what(): regex_error
Aborted (core dumped)
で始まるどんな整数!? – pm100
'\!'だけが必要だとは思わない。その特殊文字ではない – pm100
ちょうど '!'はうまくいきません –