News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

How to use RegEx in ReplaceDialog

Started by ham, December 30, 2011, 06:00:07 PM

Previous topic - Next topic

ham

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.

Alpha

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 and messing with Code::Blocks' RegEx Testbed plugin.