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
regimeketopdf
First
Argument passing by using reference and value
Throttle Example (Send two requests every two seconds)
template specialization inheritance solution
return reference (clang)
HTML Timetable generator.cpp
mddd
Делим на Ноль
C++ Standard Template Library