Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: ham on December 30, 2011, 06:00:07 pm

Title: How to use RegEx in ReplaceDialog
Post by: ham on December 30, 2011, 06:00:07 pm
hi, im totaly unfamiliar with RegEx expressions, and wish that someone can help me with a (what i think) common task for this.

I wrote a *.cpp with functions, now i like to generate a header file that only contains the declarations of the functions.

Therefore i need a expression, that searches for "{...}" after ")" and replaces everything with a single ";" so that the implementation got erased.

i.e. void foo(){...} --> void foo();

thx in advance.

EDIT: i tried {.*} with ; but it only replaces no multiline functions. what am i doing wrong?

then i tried [{][.*\n][}] but nothing found.
Title: Re: How to use RegEx in ReplaceDialog
Post by: Alpha on January 02, 2012, 06:45:55 am
Unless the functions you wrote are very simple/uniform, matching them with a regular expression would be nearly impossible (consider, for example, different numbers of nested { } braces).

What about: right-click->Insert->Class method declaration/implementation...
(If the project has access to many classes, for example if using a library, I tap on my keyboard the first letter of the name of my class multiple times to find it in the list.)

Learning RegEx is still very useful though; I would suggest reading the wxWidgets Regular Expressions Overview (http://docs.wxwidgets.org/trunk/overview_resyntax.html) and messing with Code::Blocks' RegEx Testbed plugin (http://wiki.codeblocks.org/index.php?title=RegEx_Testbed_plugin).