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 8469781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:19:27+00:00 2026-06-10T16:19:27+00:00

I’m struggling on this one and I’m to a point where I not making

  • 0

I’m struggling on this one and I’m to a point where I not making any headway and it’s time to ask for help. My familiarity with the boost libraries is only slightly better than superficial. I’m trying to do a progressive scan through a rather large string. In fact, it’s the entire contents of a file read into a std::string object (the file isn’t going to be that large, it’s the output from a command line program).

The output of this program, pnputil, is repetitive. I’m looking for certain patterns in an effort to find the “oemNNN.inf” file I want. Essentially, my algorithm is to find the first “oemNNN.inf”, search for identifying characteristics for that file. If it’s not the one I want, move on to the next.

In code, it’s something like:

std::string filesContents;
std::string::size_type index(filesContents.find_first_of("oem"));
std::string::iterator start(filesContents.begin() + index);
boost::match_results<std::string::const_iterator> matches;
while(!found) {
    if(boost::regex_search(start, filesContents.end(), matches, re))
    {
        // do important stuff with the matches
        found = true; // found is used outside of loop too
        break;
    }

    index = filesContents.find_first_of("oem", index + 1);
    if(std::string::npos == index) break;
    start = filesContents.being() + index;
}

I’m using this example from the boost library documentation for 1.47 (the version I’m using). Someone please explain to me how my usage differs from what this example has (aside from the fact that I’m not storing stuff into maps and such).

From what I can tell, I’m using the same type of iterators the example uses. Yet, when I compile the code, Microsoft’s compiler tells me that: no instance of overloaded function boost::regex_search matches argument list. Yet, the intellisense shows this function with the arguments I’m using, although the iterators are named something BidiIterator. I don’t know the significance of this, but given the example, I’m assuming that whatever the BidiIterator is, it takes a std::string::iterator for construction (perhaps a bad assumption, but seems to make sense given the example). The example does show a fifth argument, match_flags, but that argument is defaulted to the value: boost::match_default. Therefore, it should be unnecessary. However, just for kicks and grins, I’ve added that fifth argument and still it doesn’t work. How am I misusing the arguments? Especially, when considering the example.

Below is a simple program which demonstrates the problem without the looping algorithm.

#include <iostream>
#include <string>

#include <boost/regex.hpp>

int main() {
std::string haystack("This is a string which contains stuff I want to find");
boost::regex needle("stuff");

boost::match_results<std::string::const_iterator> what;
if(boost::regex_search(haystack.begin(), haystack.end(), what, needle, boost::match_default)) {
    std::cout << "Found some matches" << std::endl;
    std::cout << what[0].first << std::endl;
}

return 0;
}

If you decide to compile, I am compiling and linking against 1.47 of the boost library. The project that I’m working with uses this version extensively and updating isn’t for me to decide.

Thanks for any help. This is most frustrating.

Andy

  • 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-06-10T16:19:29+00:00Added an answer on June 10, 2026 at 4:19 pm

    In general iterator’s types are different.

    std::string haystack("This is a string which contains stuff I want to find");
    

    returning values from begin() and end() will be std::string::iterator.
    But your match type is

    boost::match_results<std::string::const_iterator> what;
    

    std::string::iterator and std::string::const_iterator are different types.
    So there is few variants

    1. declare string as const (i.e. const std::string haystack;)
    2. declare iterators as const_iterators (i.e. std::string::const_iterator begin = haystack.begin(), end = haystack.end();) and pass them to regex_search.
    3. use boost::match_results<std::string::iterator> what;
    4. if you have C++11 you can use haystack.cbegin() and haystack.cend()

    example of work

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I'm making a simple page using Google Maps API 3. My first. One marker
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

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.