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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:05:28+00:00 2026-06-06T02:05:28+00:00

std::cmatch res; std::string str = <h2>I’m a piece of text</h2>; std::regex rx(<h(.)>([^<]+)); std::regex_search(str.c_str(), res,

  • 0
std::cmatch res;
std::string str = "<h2>I'm a piece of text</h2>";
std::regex rx("<h(.)>([^<]+)");
std::regex_search(str.c_str(), res, rx);
std::cout << res[1] << ". " << res[2] << "\n";

This simple piece of code should work? right?
Apparently it doesn’t:

terminate called after throwing an instance of 'std::regex_error'
  what():  regex_error
Aborted

Compiler( gcc 4.7.0 ) bug or am I missing something?

  • 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-06T02:05:29+00:00Added an answer on June 6, 2026 at 2:05 am

    The brackets in the regex seem to be causing the problem. See this SO thread for more details and possible workarounds.

    Also (from the same thread), gcc version 4.6.1 had only partial support for std::regex, I don’t know if it has been fixed in version 4.7.0 yet

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

Sidebar

Related Questions

Alright, this is my current code snippet: namespace bai = boost::asio::ip; bai::tcp::socket tcp_connect(std::string hostname,
std::map<std::string, int> m; // Can I make assumption that m[NoSuchKey] will return 0? std::cout
std::string x(x); This crashes very badly on my compiler. Does this mean I should
std::map<String, double> m1,m2; m1[A] = 20; m2[A] = 20.01; if (m1 == m2) cout
int Socket::Connect(const std::string& host, int port) { if(this->_connected) throw Socket is already connected; //
I was trying this piece of code to check whether the divide by zero
Code: #include <iostream> #include <thread> void hello() { std::cout << Hello World << std::endl;
std::vector<std::pair<std::string > > can be used to store a list of a pair of
I wanna do something like this: int main() { try { runApp(); } catch(std::exception
Take the following code; void DoThrow( const std::exception& e ) { throw e; }

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.