Author Topic: How to use RegEx in ReplaceDialog  (Read 3314 times)

Offline ham

  • Multiple posting newcomer
  • *
  • Posts: 23
How to use RegEx in ReplaceDialog
« 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.
« Last Edit: December 30, 2011, 06:21:13 pm by ham »

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: How to use RegEx in ReplaceDialog
« Reply #1 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 and messing with Code::Blocks' RegEx Testbed plugin.