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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:31:14+00:00 2026-05-24T06:31:14+00:00

QRegExp rx(\\btest\\b); rx.indexIn(this is a test string); QString captured = rx.cap(1); std::string capturedstr =

  • 0
QRegExp rx("\\btest\\b");
rx.indexIn("this is a test string");
QString captured = rx.cap(1);
std::string capturedstr = captured.toUtf8().constData();
std::cout << capturedstr;

I wanted the above to print out test and match the word test within the string but it doesn’t seem to be doing that. Could anyone shed some light here? Using QT.

  • 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-05-24T06:31:14+00:00Added an answer on May 24, 2026 at 6:31 am

    You don’t have any capturing parens in your regex so there is no capture group 1. Try this instead:

    QRegExp rx("\\b(test)\\b");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I use QString::replace to detect URLs in a string and replace them
suppose I have a string: QString str={time:123,age:{aaa:123,bbb:456},address:aaa,hight:{zzz:111,ccc:{rrr:333,uuu:555},xxx:222}}; is it possible using regular expression to
i needed to match a string like the following: XXX But both 1. and
What a best way for trimming all strings in string list? I try to
I have no clue how to use QRegExp . I am trying to remove
I have a problem with Regular Expressions. Consider we have a string S= [sometext1],[sometext],[sometext]....,[sometext]
I'm having trouble splitting a QString properly. Unless I'm mistaken, for multiple delimiters I
I am struggling to understand this simple regular expression. I have the following attempt:
I'm converting an application from the .Net framework to Qt using C++. The application
I am currently working on a Qt C++ application on Mac. Throughout the application

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.