Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Alternation regex
#include <regex> #include <string> #include <iostream> int main() { std::string line = "abcde"; { const std::string RX_ION_TYPE("ab?|ab?(?:cd|dc)"); const auto regexType = std::regex::ECMAScript; std::regex rx_ionType; rx_ionType.assign( "(" + RX_ION_TYPE + ")" , regexType); std::smatch match; if (std::regex_search(line, match, rx_ionType)) { for (int i = 0; i < match.size(); i++) { std::cout << "|" << match.str(i) << "|\n"; } } else { std::cout << "No match.\n"; } } { const std::string RX_ION_TYPE("ab?(?:cd|dc)|ab?"); const auto regexType = std::regex::ECMAScript; std::regex rx_ionType; rx_ionType.assign( "(" + RX_ION_TYPE + ")" , regexType); std::smatch match; if (std::regex_search(line, match, rx_ionType)) { for (int i = 0; i < match.size(); i++) { std::cout << "|" << match.str(i) << "|\n"; } } else { std::cout << "No match.\n"; } } { const std::string RX_ION_TYPE("ab?(?:cd|dc)?"); const auto regexType = std::regex::ECMAScript; std::regex rx_ionType; rx_ionType.assign( "(" + RX_ION_TYPE + ")" , regexType); std::smatch match; if (std::regex_search(line, match, rx_ionType)) { for (int i = 0; i < match.size(); i++) { std::cout << "|" << match.str(i) << "|\n"; } } else { std::cout << "No match.\n"; } } return 0; }
run
|
edit
|
history
|
help
0
mine
unordered graphs search
Variadic Template: Make Index Sequence
is_convertible
std::99 bottles of beer!
"nearest enclosing namespace"
New wall
C++ Operator Overloading
tuple, order of members
hw1 Os