Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Does boost::regex_search support branch sentence like (....)|(....)?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="¿ÖÐ, post: 3540989"] #include <iostream> #include <string> #include <boost/regex.hpp> using namespace std; int main(int argc, char* argv[]) { string inStr = "123456" "abcde" "1-2"; std::string regstr = "(\\d+)|" "(a-z)"; boost::regex _reg(regstr); boost::smatch what; std::string::const_iterator _start = inStr.begin(); std::string::const_iterator _end = inStr.end(); while (boost::regex_search(_start, _end, what, _reg)) { std::string msg1(what[1].first, what[1].second); cout << msg1.c_str() << endl; _start = what[1].second; } return 0; } run result: 123456 1 2 why can't find "abcde"? [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Does boost::regex_search support branch sentence like (....)|(....)?
Top