Skip to content

Instantly share code, notes, and snippets.

@chezou
Created November 26, 2011 01:09
Show Gist options
  • Save chezou/1394782 to your computer and use it in GitHub Desktop.
Save chezou/1394782 to your computer and use it in GitHub Desktop.
Sample code of re2 using FindAndConsume for repeatable match
#include <iostream>
#include <string>
#include <re2/re2.h>
#include <vector>
using namespace std;
int main(){
string str("あぶらかたぶら");
re::RE2 re("(.ぶ)");
re2::StringPiece input(str);
string r;
while(re2::RE2::FindAndConsume(&input, re, &r) ){
cout << r << endl;
}
return 0;
}
@Spixmaster
Copy link

Spixmaster commented Jul 27, 2024

This works! Thank you very much.

However, searching for regular expression "por." requires to pass "(por.)" and not just "por.".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment