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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:07:07+00:00 2026-06-09T05:07:07+00:00

FI have many code which contains code snippet like: #if wxCHECK_VERSION(2, 9, 0) Codef(

  • 0

FI have many code which contains code snippet like:

#if wxCHECK_VERSION(2, 9, 0)
Codef( _T("%AAppend(%t)"), ArrayChoices[i].wx_str());
#else
Codef( _T("%AAppend(%t)"), ArrayChoices[i].c_str());
#endif

But I want to clean the code to

Codef( _T("%AAppend(%t)"), ArrayChoices[i].wx_str());

I mean, I need to strip the preprocessor directive, and only leave the first branch.

The match condition should be:

#if wxCHECK_VERSION(2, 9, 0)
blablabla1
#else
blablabla2
#endif

The content of blablabla1 and blablabla2 should be the same only except the wx_str and c_str.

See here, someone said it can be handled by regex, but I have no idea, can you help me? Thanks.

EDIT:
I just want to strip the #else branch, and only keep the first branch contents.

Here is the reference page:

Re: what’s the best and quick way to remove all the wx_str and c_str preprocessor

  • 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-09T05:07:09+00:00Added an answer on June 9, 2026 at 5:07 am

    Search

    This regex works for your examples:

    \s+#if wxCHECK_VERSION\(2\, 9\, 0\)\s*(.*?)wx_str([^\r\n]*?)\s*#else\s*(\1)c_str(\2)\s*#endif

    Replacement

    Regexr.com: Replace with: $1wx_str$2. Don’t forget to select dotall option.

    Notepad++: Replace with: \1wx_str\2. Don’t forget to select . matches newline option.

    Batch Mode

    Notepad++ allows to find/replace in batch mode.

    1. Open "Find in Files" dialog pressing Ctrl+Shift+H.
    2. Copy-paste above regex to "Find what" box.
    3. Copy-paste above replacement (\1wx_str\2) to "Replace with" box.
    4. Specify Directory to find/replace in it.
    5. Select Regular Expression in Search mode group box.
    6. Check the . matches newline box.
    7. Click to "Find All" button to view matches.
    8. Click to "Replace in Files" button when you are sure to replace everything.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

-In my c code I have a struct which contains many unknown sized arrays
I have a cart which contains many line_items. I'd like to have a delete
I have WPF Form which has many buttons with the same code. Appearance of
I have a page which has many event handlers. The code now reached 1000+
Basic question here - I have many lines of code that look something like:
i have a txt file which contains many chinese characters, and the txt file
I have a directory which contains several files, many of which has non-english name.
I have a wicket form which contains many TextField input components. There's a Validator
i got an inputfile which contains a javascript code which contains many five-figure ids.
I have a page in chrome which contains many textboxes and I wish to

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.