Created
November 25, 2011 15:42
-
-
Save chezou/1393827 to your computer and use it in GitHub Desktop.
Sample cord of re2 of PartialMatchN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <re2/re2.h> | |
#include <vector> | |
using namespace std; | |
int main(){ | |
string str("あぶらかたぶら"); | |
re::RE2 re("(.ぶ)"); | |
re2::StringPiece input(str); | |
int groupSize = re.NumberOfCapturingGroups(); | |
vector<re2::RE2::Arg> argv(groupSize); | |
vector<re2::RE2::Arg*> args(groupSize); | |
vector<re2::StringPiece> ws(groupSize); | |
for (int i = 0; i < groupSize; ++i) { | |
args[i] = &argv[i]; | |
argv[i] = &ws[i]; | |
} | |
re2::RE2::PartialMatchN(input, re, &(args[0]), groupSize); | |
cout << groupSize << endl; | |
for (int i = 0; i < groupSize; ++i) | |
cout << ws[i] << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment