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
wasm test for node
New wall
Atomic trivial default constructor
hw 1 os
vf
Random values and probability distribution
for_each_argument
Thread-safe Interval Average Calculator
Dash-D compiler flag example
Saam hash example