이것도 누군가의 문제를 해결하는 데 도움이됩니다.
{},와 같은 패턴을 가진 중괄호 ( )
안의 내용을 분할합니다 {'day': 1, 'count': 100}.
예를 들면 :
#include <iostream>
#include <regex>
#include<string>
using namespace std;
int main()
{
//string to be searched
string s = "{'day': 1, 'count': 100}, {'day': 2, 'count': 100}";
// regex expression for pattern to be searched
regex e ("\\{[a-z':, 0-9]+\\}");
regex_token_iterator<string::iterator> rend;
regex_token_iterator<string::iterator> a ( s.begin(), s.end(), e );
while (a!=rend) cout << " [" << *a++ << "]";
cout << endl;
return 0;
}
산출:
[{'day': 1, 'count': 100}] [{'day': 2, 'count': 100}]