Created
October 18, 2014 04:33
-
-
Save jasonlvhit/4dc78cf9c032cbfa6957 to your computer and use it in GitHub Desktop.
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
int main(){ | |
std::string pattern = "^<([\\w|_]+)>\\s*::=\\s*(.*)"; | |
std::regex p(pattern); | |
std::smatch piece; | |
string r = "<iter_stmt> ::= WHILE(<expression>) <stmt>"; | |
std::regex_match(r, piece, p); | |
cout << piece.size() << endl; | |
for (size_t i = 0; i < piece.size(); ++i) { | |
std::ssub_match sub_match = piece[i]; | |
std::string piece = sub_match.str(); | |
std::cout << " submatch " << i << ": " << piece << '\n'; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment