Boost Regular Expression

Source: Internet
Author: User

Recently, I used a regular expression to make a little thing, because I used C ++ to catch up with the trend. I used boost: xpressvie to get started, everything works normally on an HP Server, and then compiled on the sun server. I found that the compilation was not successful, and I fainted. Fortunately, I submitted a report to the boost website in time, otherwise, it will be a waste of time. Currently, I switched to the boost: RegEx module, but encountered a problem and found the following regular expression (0 | 1) + ,?) + For the short term of 00101010, there is no problem. When the string of 001010 is very long, an error is thrown directly, and the buddy does not know what is going on. Boost: xpressive
You do not know when the resolution can be completed.

Experiments at home are fast:

# Include "Boost/xpressive/xpressive_dynamic.hpp"
Using namespace boost: xpressive;

Void test_bitmap (){

Sregex Reg = sregex: Compile ("(1 | 0) + ,?) + ");
STD: String datas [] = {
"Aaa-1 & bbb-0 & ccc-1 ",
"1111000111 ",
"11001010,101100100101010010101 ",
"10010100101100110010101010101001010,101010 ",
"100101001010110011001010101010100101010101010 "};
For (INT I = 0; I <sizeof (datas)/sizeof (STD: string); ++ I ){
STD: cout <"match result:" <regex_match (datas [I], Reg) <", data:" <datas [I] <STD :: endl;
}
}

Int main (){
Cregex Reg = cregex: Compile ("(\ s * \ D + \ s * | (\ [| \\() \ s * \ D + \ s *, \ s * \ D + \ s * (\] | \\))) (\ s *, \ s * (\ s * \ D + \ s * | (\ [| \\() \ s * \ D + \ s *, \ s * \ D + \ s * (\] | \\))))*");
STD: cout <regex_match ("[10,100), 1, 8", Reg );

Test_bitmap ();
Return 0;
}

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.