Regular expression 'substitution variables'?

Asked by Daniel on 2008-02-07

Hello,

  A two part question:

  The first is a hopefully simple yes/no question: In KDevelop's Replace dialog, there is a possibility to use a regular expression as a match. This is great. However - having some experience with Perl's s/// operator, I was wondering if the feature I think is called "substitution variables" are possible in the KDevelop RegEx ?

  To describe it in more detail : I was playing around with some pointer-to-functions in a C++ project and having quite a few of these to initialize, I simply copied the body my pointer structure into the initializing code. I ended up with a lot of lines like:

  void (*my_function)(const long, object*);

  ...so I used the RegEx matching to strip away first the " void (*" part and then a second sweep to take away all ")(const long, object*)" junk afterwards in order to get a nice clean list of the structure's pointers.

  In Perl I could have done all that with one sweep - with something like this (a bit complex I know, but this is what I was trying to do...): s/^\s+[A-Za-z]\s+\(\*([A-Za-z0-9_])\)\([A-Za-z0-9_,*& ]*\)/$1/

  Or split in its two parts:
  Search for: ^\s+[A-Za-z]\s+\(\*([A-Za-z0-9_])\)\([A-Za-z0-9_,*& ]*\)
  Replace with: $1

  The important bit is the middle part ...([A-Za-z0-9_])... The unescaped paranthesis pair assigns the matching expression to the variable $1 and I can then use it in the replace part of the substitution.

  Ok, that was question 1.

  Question 2: if this is not a feature of KDevelop - where can I submit such a suggestion ?

Cheers!
/ Daniel

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu kdevelop Edit question
Assignee:
No assignee Edit question
Solved by:
Daniel
Solved:
2008-02-08
Last query:
2008-02-08
Last reply:
Daniel (johdaniel) said : #1

I got it - "Use placeholders" ! That seems to be it!