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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:48:11+00:00 2026-06-16T08:48:11+00:00

I have a text file which looks like this: VariableA = 10 VariableB =

  • 0

I have a text file which looks like this:

VariableA = 10 VariableB = 20 VariableC = “Hello World”

The code works fine, but my trouble is getting the text strings between ” “.

QStringList Data;
Data << "VariableA = " << "VariableB = " << "VariableC = ";
QStringList Values;

int VariableA;
int VariableB;
QString VariableC;


foreach(const QString &DataToFind, Data) {
    QRegExp DataExpression(DataToFind);
    int DataStart = DataExpression.indexIn(TextToFind);
    if(DataStart >= 0) {
        int DataLength = DataExpression.matchedLength();
        int ValueSize = 1;
        while(TextToFind.at(DataStart + DataLength + ValueSize) != QChar(' ')) {
            ValueSize++;
        }
        QStringRef DataValue(&TextToFind, DataStart + DataLength, ValueSize);
        Values += DataValue.toString(); 
        DataStart = DataExpression.indexIn(description, DataStart + DataLength);
    } else {
        continue;
    }
}

VariableA = Values[0].toInt();
VariableB = Values[1].toInt();
VariableC = Values[2];

The issue is that the text on VariableC can have spaces and/or ” (double quotes) inside it. So the method I’ve posted above to retrieve the variables from the file is useless. Since it uses ” ” to reach end of variable in the file.

How can I retrieve the full text inside the double quotes?

  • 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-16T08:48:12+00:00Added an answer on June 16, 2026 at 8:48 am
    QStringList Data;
    Data << "A = " << "B = " << "X = ";
    
    int A;
    int B;
    QString X;
    
    foreach(const QString &DataToFind, Data) {
        QRegExp DataExpression(DataToFind);
        int DataStart = DataExpression.indexIn(TextToFind);
        if(DataStart >= 0) {
            int DataLength = DataExpression.matchedLength();
            int ValueSize = 1;
            while(TextToFind.at(DataStart + DataLength + ValueSize) != QChar(' ')) {
                ValueSize++;
            }
            QStringRef DataValue(&TextToFind, DataStart + DataLength, ValueSize);
            DataStart = DataExpression.indexIn(description, DataStart + DataLength);
        } else {
            continue;
        }
    }
    

    This does the work.

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

Sidebar

Related Questions

I have a text file which looks like this: code appearance ---------------- j4t8 1
I have a text file, which looks like this: node13 state = free np
I have a text file which contains something like this: Hello, my name is
I have a csv file which looks like this $lines[0] = text, with commas,
I have a text file which looks like this: blah blah foo1 bar1 foo1
I have a text file which I'm trying to parse. The file looks like
So I have a a text file that looks something like this: public >ret
I do have some text(template), which looks like Hello @FirstName, Welcome to @Address. The
I have 100 text files which look like this: File title 4 Realization number
Say I have an XML file which looks like this: <?xml version=1.0 encoding=UTF-8?> <Project

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.