Created
July 24, 2010 08:36
-
-
Save sebfisch/488543 to your computer and use it in GitHub Desktop.
C++ program that matches a regular expression using Google's re2 library
This file contains hidden or 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> | |
using namespace std; | |
using namespace re2; | |
int main(int argc, char* args[]) { | |
// not syncing C++ and C I/O is faster with simple matchings | |
ios_base::sync_with_stdio(false); | |
RE2 re(args[1], RE2::Latin1); // Latin1 is faster than UTF-8 | |
string input; getline(cin, input); | |
cout << (RE2::PartialMatch(input, re) ? "" : "no ") << "match"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment