Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 708323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:22:41+00:00 2026-05-14T04:22:41+00:00

I am using Boost to match substrings in a string. Io iterate over the

  • 0

I am using Boost to match substrings in a string. Io iterate over the results, I need to use regex_iterator().

That is the only usage example I have found, but I do not understand the callback. Could someone give me an example uage of the function?


Let us assume that my input text is:

"Hello everybody this is a sentense
Bla bla 14 .. yes 
date 04/15/1986 
"

I want to get:

"Hello" "everybody" "this" "is" "a" "sentense" "bla" "yes" "date"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:22:41+00:00Added an answer on May 14, 2026 at 4:22 am

    If the only part of the example you don’t understand is the callback, consider that:

    std::for_each(m1, m2, &regex_callback);
    

    is roughly equivalent to:

    for (; m1 != m2; ++m1){
        class_index[(*m1)[5].str() + (*m1)[6].str()] = (*m1).position(5);
    }
    

    Assuming that, in your case, you want to store all the matches in a vector, you would write something like:

    //Warning, untested:
    boost::sregex_iterator m1(text.begin(), text.end(), expression);
    boost::sregex_iterator m2;
    std::vector<std::string> tokens;
    for (; m1 != m2; ++m1){
        tokens.push_back(m1->str()).
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using the pImpl idiom is it preferable to use a boost:shared_ptr instead of
I have just started using Boost 1.36. These libraries would be very useful in
I'm using boost for several C++ projects. I recently made a upgrade (1.33.1 to
I'm using boost's shared pointers, and enable_shared_from_this to enable returning a shared pointer to
What might be the best way to start programming using boost lambda libraries.
So I am doing a lot of high performance network programming using Boost::Asio (or
I am experiencing a crash while using the Boost.Spirit and Boost.Thread libraries in my
How much do using smart pointers, particularly boost::shared_ptr cost more compared to bare pointers
Since I have started using this site, I keep hearing about the Boost library.
I'm trying setup a subset of boost and get it properly compiled using bjam,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.