Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
RegexMatch
//g++ 7.4.0 //RegexMatch //this code is created by Rezaul Hoque on February 21,2022;contact: jewelmrh@yahoo.com,Dhaka, Bangladesh //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <iostream> #include <string> #include <regex> int main () { if (std::regex_match("Holistic", std::regex("([hH]ol)(.*)") )) std::cout << "string literal matched\n"; const char csl[] = "Holistic"; std::string so ("Holistic"); std::regex rg ("([hH]ol)(.*)"); if (std::regex_match (so,rg)) std::cout << "string object matched\n"; if ( std::regex_match ( so.begin(), so.end(), rg ) ) std::cout << "range matched\n"; std::match_results<const char*> cm; std::regex_match (csl,cm,rg); std::cout << "string literal with " << cm.size() << " matches\n"; std::match_results<std::string::const_iterator> sm; std::regex_match (so,sm,rg); std::cout << "string object with " << sm.size() << " matches\n"; std::regex_match ( so.cbegin(), so.cend(), sm, rg); std::cout << "range with " << sm.size() << " matches\n"; std::regex_match ( csl, cm, rg, std::regex_constants::match_default ); std::cout<<"And the match:\n"; for (unsigned i=0; i<cm.size(); ++i) { std::cout << "[" << cm[i] << "] "; } std::cout << std::endl; return 0; }
run
|
edit
|
history
|
help
0
Operators
3
Grundy Number
epsilon
completed
PalindromeDay
-fno-elide-constructors
Minimum Vertices to Traverse Directed Graph
Pairs with given sum
Zadanie Kalkulator z bajerami