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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:20:28+00:00 2026-06-15T18:20:28+00:00

boost::regex re((abc)(.*?)); boost::smatch m; std::string str = abcdlogin; boost::regex_search(str, m, re); I found m[1].first

  • 0
boost::regex re("(abc)(.*?)");
boost::smatch m;
std::string str = "abcdlogin";
boost::regex_search(str, m, re);

I found m[1].first is “abcdlogin”, m[1].second is “dlogin”.

But I think is m[1].first should be “abc”?

  • 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-15T18:20:29+00:00Added an answer on June 15, 2026 at 6:20 pm

    As noted in the documentation:

    m[n].first: For all integers n < m.size(), the start of the sequence
    that matched sub-expression n. Alternatively, if sub-expression n did
    not participate in the match, then last.

    m[n].second: For all integers n < m.size(), the end of the sequence
    that matched sub-expression n. Alternatively, if sub-expression n did
    not participate in the match, then last.

    Note how they are iterators into the matching sub-expression.
    In your example, if you want a string with "abc", you can construct a string like this: std::string s(m[1].first, m[1].second);.

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

Sidebar

Related Questions

I have these variables: boost::regex re //regular expression to use std::string stringToChange //replace this
I've been using Boost::regex and Boost::regex_search and found that when I run the regex
My code: #include <string> #include <boost/algorithm/string/regex.hpp> std::cout << boost::algorithm::replace_regex_copy( {x}{y}, // source string boost::regex(\\{.*?\\}),
#include <boost/regex.hpp> #include <string> #include <iostream> using namespace boost; static const regex regexp( std::vector<
#include <boost/regex.hpp> #include <string> #include <iostream> using namespace boost; static const regex regexp( std::vector<
Considering the C++11 function with the signaturer std::regex_match( std::string const&, std::smatch& match, std::regex const&
include #include <algorithm> #include<boost/algorithm/string.hpp> #include<boost/regex.hpp> using namespace std; using namespace boost; string _getBasehtttp(string url)
include #include <fstream> #include <string> #include<string> #include<boost/algorithm/string.hpp> #include<boost/regex.hpp> #include <boost/algorithm/string/trim.hpp> using namespace std; using
I'm trying to get all words inside a string using Boost::regex in C++. Here's
My code is: #include <boost/regex.hpp> boost::cmatch matches; boost::regex_match(alpha beta, matches, boost::regex(([a-z])+)); cout << found:

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.