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

  • Home
  • SEARCH
  • 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 7706985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:14:48+00:00 2026-06-01T00:14:48+00:00

(or so I think)… I’m using boost::xpressive as my regular expression engine to parse

  • 0

(or so I think)…

I’m using boost::xpressive as my regular expression engine to parse something and I get a segfault. I suspect that recursivity and my bad regular expression are to blame, because gdb shows more than 300 stack frames. So, here is my (case-sensitive) regular expression, in perl/python notation:

begin([^e]+)e((?:[^b]|b(?!egin))+)

which I expect to match

beginHEADER HEREeFOLLOWED BY SOME LONG LONG TEXT THAT GOES UNTIL NEXTbegin

with the first uppercase text (HEADER HERE) in the first group, and the second uppercase text in the second group. I always get the segfault if the text that should match group 2 is very long.

Why shouldn’t this work?

  • 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-01T00:14:50+00:00Added an answer on June 1, 2026 at 12:14 am

    You can simplify your regular expression a lot by simply using non-greedy matching:

    begin(.+?)e(.+?)begin
    

    Try that and see if it works better.

    It’s likely that your original regex was causing a stack overflow due to a recursive implementation of the |-or grouping in your regex, which was potentially branching with every single character in your second group.

    A simple non-greedy .+? on the other hand doesn’t need to branch for every single character.

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

Sidebar

Related Questions

I think that java executables (jar files) are trivial to decompile and get the
I think that I have a quite strange question. I am using a class
I think that I am misunderstanding something about how jquery $(this) works. In my
I think the file that is produced is an .asm file, any idea how
I think that asking this might be kind of silly but I'm still wondering
Think that I have many activities,and all I want is this: I have a
I think I'm missing something basic here. Why is the third IF condition true?
Think that says it all?
I think that there are some issues with the earth Gravity, so I wonder
I think that I am stuck with this particular situation: Here are my tables:

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.