News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Regular Expresssions in Search and Replace

Started by Wahooney, April 08, 2007, 02:00:51 PM

Previous topic - Next topic

Wahooney

Can anyone point me to a reference sheet for regular expressions in the search and replace in Code::Blocks?

Certain expressions don't work that I'm familiar with, eg. if I search for (thing) and replace it with my_\1 I expect thing to be replaced with my_thing, which I don't get, S&R just closes as if there is nothing to find or replace.

Thanks guys.
Fabricati Diem, Celerata!

dje

Hi !

Did you try $1 instead of \1 in your replacement pattern ?

Dje

Wahooney

I tried that, but it seems the the problem is with ().
Fabricati Diem, Celerata!

dje

Little tricky but I found the solution.
Just put \ before parenthesis (or reg exp special chars).

For example, to replace class name in :
class foo : public bar
{
}


Put in search :
class \([a-zA-Z0-9_]+\) :

and in replace:
class my_\1 :

It works ! :D

Dje

dmoore

Quote from: Wahooney on April 08, 2007, 07:53:43 PM
I tried that, but it seems the the problem is with ().

if you are using a nightly from this year you can switch on POSIX style regexes in editor settings, which uses (group) to enclose groups instead of \(group\)

if you are using a nightly from last week or more recent you can switch on advanced regex find and replace in editor settings and get even more advanced syntax: http://www.wxwidgets.org/manuals/stable/wx_wxresyn.html#wxresyn
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

Wahooney

I solved this a week ago, I should have let everyone know :oops:, thanks for all the help guys.
Fabricati Diem, Celerata!