Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that the compiler properly supports regex
- Loading branch information
Showing
4 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
palaver.so | ||
palaver.so | ||
test-regex |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <iostream> | ||
#include <regex> | ||
|
||
|
||
int main(int argc, const char *argv[]) { | ||
std::smatch match; | ||
std::string message = "Hello nickname."; | ||
std::string matcher = "\\bnickname\\b"; | ||
|
||
try { | ||
std::regex expression = std::regex(matcher, std::regex_constants::ECMAScript | std::regex_constants::icase); | ||
std::regex_search(message, match, expression); | ||
} catch (std::regex_error& error) { | ||
std::cout << "Your C++ compiler doesn't properly support regex. Please upgrade to GCC 4.9, Clang or newer.\n"; | ||
return 1; | ||
} | ||
|
||
if (match.empty()) { | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |