Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // RegexTester.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <string>
- #include <iostream>
- #include <ctime>
- #include "re2/re2.h"
- bool match_an_re2(int n){
- std::string theRegexString;
- std::string theText;
- for (int i = 0; i < n; i++){
- theRegexString = "a?" + theRegexString + "a";
- theText += "a";
- }
- clock_t t = clock();
- bool ret = RE2::FullMatch(theText, theRegexString);
- t = clock() - t;
- std::cout << "Matching (a?)^na^n on a^n for n = " << n << " we get a " << ret << " in " << ((float)t) / CLOCKS_PER_SEC << " seconds." << std::endl;
- return ret;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- for (int i = 1; i < 100; i++){
- match_an_re2(i);
- }
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment