Skip to content

Instantly share code, notes, and snippets.

@WindAzure
Last active March 31, 2019 16:24
Show Gist options
  • Save WindAzure/72309137d292c2398087d73125d86607 to your computer and use it in GitHub Desktop.
Save WindAzure/72309137d292c2398087d73125d86607 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string>
#include <regex>
#include <iterator>
#include <iostream>
using namespace std;
int main()
{
auto result = vector<string>{};
auto input = string{ "I am apple" };
regex pattern(string{ " " });
copy(sregex_token_iterator(input.begin(), input.end(), pattern, -1), sregex_token_iterator(), back_inserter(result));
//copy(sregex_token_iterator(input.begin(), input.end(), pattern, -1), sregex_token_iterator(), ostream_iterator<string>(cout, "\n"));
//for (auto it = sregex_token_iterator(input.begin(), input.end(), pattern, -1); it != sregex_token_iterator(); it++)
//{
// cout << *it << endl;
//}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment