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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:46:51+00:00 2026-05-11T02:46:51+00:00

I have an text that consists of information enclosed by a certain pattern. The

  • 0

I have an text that consists of information enclosed by a certain pattern. The only thing I know is the pattern: ‘${template.start}’ and ${template.end} To keep it simple I will substitute ${template.start} and ${template.end} with ‘a’ in the example.

So one entry in the text would be:

aINFORMATIONHEREa 

I do not know how many of these entries are concatenated in the text. So the following is correct too:

aFOOOOOOaaASDADaaASDSDADa 

I want to write a regular expression to extract the information enclosed by the ‘a’s.

My first attempt was to do:

a(.*)a 

which works as long as there is only one entry in the text. As soon as there are more than one entries it failes, because of the .* matching everything. So using a(.*)a on aFOOOOOOaaASDADaaASDSDADa results in only one capturing group containing everything between the first and the last character of the text which are ‘a’:

FOOOOOOaaASDADaaASDSDAD 

What I want to get is something like

captureGroup(0):  aFOOOOOOaaASDADaaASDSDADa captureGroup(1): FOOOOOO captureGroup(2): ASDAD captureGroup(3): ASDSDAD 

It would be great to being able to extract each entry out of the text and from each entry the information that is enclosed between the ‘a’s. By the way I am using the QRegExp class of Qt4.

Any hints? Thanks! Markus


Multiple variation of this question have been seen before. Various related discussions:

  • Regex to replace all \n in a String, but no those inside [code] [/code] tag
  • Using regular expressions how do I find a pattern surrounded by two other patterns without including the surrounding strings?
  • Use RegExp to match a parenthetical number then increment it
  • Regex for splitting a string using space when not surrounded by single or double quotes
  • What regex will match text excluding what lies within HTML tags?

and probably others…

  • 1 1 Answer
  • 3 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. 2026-05-11T02:46:52+00:00Added an answer on May 11, 2026 at 2:46 am

    Simply use non-greedy expressions, namely:

    a(.*?)a 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have text that starts with (parag1 level=All) as start tag and end with
Suppose I have a text that I can easily parse. It consists of text
I have an android activity that consists of a List View and a Text
I have a text that consists of more than 6000 lines but I have
I have a string that consists of some text \\computername.example.com\admin$. How would I do
I have a form that consists of: 3 text boxes (first two are required
I have a large form that consists of all the input (text, checkbox, radio,
I have a JavaScript overlay that consists of several input text search criteria. When
I have text that looks like: My name is (Richard) and I cannot do
Currently I am doing this: I have text that looks like: Hello ${user.name}, this

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.