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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:47:46+00:00 2026-06-07T23:47:46+00:00

I want use regex to find something in string (or QString) that is between

  • 0

I want use regex to find something in string (or QString) that is between ” (quotes).

My simple String: x=”20.51167″ and I want 20.51167.

Is it possible with Regular Expressions ??

On start I had somthing like this string :

<S id="1109" s5="1" nr="1183" n="Some text" test=" " x="20.53843" y="50.84443">

Using regexp like: (nr=\"[0-9]+\") (y=\"[0-9 .^\"]+\")" etc I get my simple string like x=”20.51167″. Maybe this is wrong way and I can get value that is between quotes at one time ??

  • 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-07T23:47:49+00:00Added an answer on June 7, 2026 at 11:47 pm

    For your particular example, this will work:

    #include <QRegExp>
    #include <QString>
    #include <iostream>
    int main()
    {
        //Here's your regexp.
        QRegExp re("\"[^\"^=]+\"");
        //Here's your sample string:
        QString test ="<S id=\"1109\" s5=\"1\" nr=\"1183\" n=\"Some text\" test=\" \" x=\"20.53843\" y=\"50.84443\">";
        int offset = 0;
        while( offset = re.indexIn( test, offset + 1 ) )
        {
            if(offset == -1)
                break;
            QString res = re.cap().replace("\"", "");
            bool ok;
            int iRes;
            float fRes;
            if( res.toInt( &ok ) && ok )
            {
                iRes = res.toInt();
                std::cout << "int: " << iRes << std::endl;
            }
            else if ( res.toFloat( &ok ) && ok )
            {
                fRes = res.toFloat();
                std::cout << "float: " << fRes << std::endl;
            }
            else
                std::cout << "string: " << res.toStdString() << std::endl;
        }
    }
    

    The output will be;

    int: 1109
    int: 1
    int: 1183
    string: Some text
    string:  
    float: 20.5384
    float: 50.8444
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use a regex to find a particular string in my sample,
If i want to use regex to find either < or > within a
I want to use this regular expression in Python: <(?:[^]*[']*|'[^']*'[']*|[^'>])+> (from RegEx match open
Is it possible to use stored variables in R's regex? For example I want
I want to use regex to replace src html attributes. The HTML is not
I want to validate text-boxes in JQuery bit I want to use regex for
I don't know if I can use regex for this, but I want to
I want to use a variable in a regex, like this: variables = ['variableA','variableB']
Is there a way to use regex to reformat a string? I've a string
I'm trying to extract only certain elements of a string using regular expressions and

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.