Use regular expressions in vc6 to parse strings

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.