From: http://school.cnd8.com/vc/jiaocheng/33274.htm
Refer toArticle, Wrote the following example, environment: Windows XP SP3 + vc6
# Include <cstdlib> # include <stdlib. h> # include <boost/RegEx. HPP> # include <string> # include <iostream> using namespace STD; using namespace boost; int main (INT argc, char * argv []) {RegEx expression ("(\ D +)-(\ D +)"); // note the escape method string in ("today: 2007-06-23 "); cmatch what; // if you use regex_match, You need to perform a full match. // you cannot search for the mode in the string. It can be used to verify the input if (regex_search (in. c_str (), what, expression) {for (INT I = 0; I <what. size (); I ++) {cout <"str:" <what [I]. STR () <Endl ;}} return 0 ;}
ProgramRunning result:
STR: 2007-06-23
STR: 2007
STR: 06
STR: 23
Press any key to continue
Note:
The boost library version used in this article is:Boost_000034_0. Please be clear.The boost library of a later version no longer supports vc6Instead, Visual Studio IDE (later than 7.1) is supported ).
In addition, before compilation, You need to copy the libboost_regex-vc6-sgd-1_34.lib to the program root directory, the file is generated in "nmake-F vc6.mak.