Last active
August 29, 2015 13:59
-
-
Save kazmura11/10982891 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
#include <iostream> | |
#include <string> | |
#include <regex> | |
int main() | |
{ | |
std::vector<std::string> test = { | |
"Windows 8", | |
"Windows8", | |
"Microsoft Windows8", | |
"MicrosoftWindows8", | |
"Windows8.1", | |
"MicrosoftWindows8.1", | |
"Windows 8.1", | |
"Windows 8.1 Update 1", | |
"MicrosoftWindows8.1Update1", | |
"Microsoft Windows 8.1 Update 1", | |
"microsoft windows 8.1 update 1", | |
"Microsoft windows 8.2 update 1", | |
}; | |
std::regex pattern("([Mm]icrosoft)?\\s*([Ww]indows)\\s*(8\\.1)\\s*([Uu]pdate)?.*"); | |
std::smatch sm; | |
int line = 1; | |
for (auto it = test.begin(); it != test.end(); ++it) | |
{ | |
if (std::regex_match(*it, sm, pattern)) | |
{ | |
std::cout << line << "個目の [" | |
<< sm[0] << "] がマッチしました\n"; | |
} | |
line++; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment