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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:31:11+00:00 2026-06-10T02:31:11+00:00

Please help me with the regular expression itself. I am learning it. I don’t

  • 0

Please help me with the regular expression itself. I am learning it. I don’t need replacement code.

I am working on wxWidget 2.8.12 with VS2008 (C++). I’d like to check whether TEST_STRING is float number. (-0.1, 0.1, 1 etc.). I think the expression itself is correct, I checked by tools. Do I make mistake with wxWidget?

wxString tmpStr = TEST_STRING;
wxRegEx reNegativeFloatNum(_("^[-]?[0-9]*\\.?[0-9]+$"));
bool tmp = reNegativeFloatNum.Compile(tmpStr);
     tmp = tmp && reNegativeFloatNum.IsValid();
if ( tmp && reNegativeFloatNum.Matches(tmpStr))
{
    //Do something
}
else
{
    //Do something else
}

My real question is why the regular expression doesn’t work? If I input ‘a’-‘Z’, the Matches() return ‘true’. Any one know? I just want to learn the regular expression.

  • 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-10T02:31:13+00:00Added an answer on June 10, 2026 at 2:31 am

    As the OP really wants to use regexes, I looked at it in details and the original regex works just fine to me. Notice that you don’t need to use _() around regex string as this is not something you’d ever need to translate (_ is a short synonym for wxTRANSLATE()) and that Compile() is already called by the ctor. So here is a shorter version:

    #include <wx/init.h>
    #include <wx/regex.h>
    
    int main(int argc, char **argv)
    {
        wxInitializer init;
        if ( !init.IsOk() ) {
            puts("Failed to initialize wxWidgets.");
            return 1;
        }
    
        wxRegEx re("^[-]?[0-9]*\\.?[0-9]+$");
        return re.Matches(argv[1]);
    }
    

    And it works as expected:

        % ./a.out 123 || echo matches
        matches
        % ./a.out a-Z || echo matches
        <<<nothing>>>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a Regular Expression for Atleast 6 characters with no spaces Please help
Please help me find a regular expression to parse the data like this: 'EBB112'
I need some help with a regular expression, please help if you can I
just need help with regular expression in mysql query please: column ISRC GBCQV0700378 GBCQV0700382
Please help me with regular expression. I found this good peace of code: var
Can you please help to derive a regular expression that matches the bold-italics portion
Can some please help me with regular expression for height in cm ( eg.
Please help me with a regular expression to validate the following format dd/mm This
can someone please help me to compose a regular expression to check an alphanumeric
can someone please help me to compose a regular expression to check a currency

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.