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
Search
This regex works for your examples:
Replacement
Regexr.com: Replace with:
$1wx_str$2. Don’t forget to selectdotalloption.Notepad++: Replace with:
\1wx_str\2. Don’t forget to select. matches newlineoption.Batch Mode
Notepad++ allows to find/replace in batch mode.
\1wx_str\2) to "Replace with" box.. matches newlinebox.