hnodrog
hnodrog

Reputation: 78

Colon in Visual Studio's RegEx

I realise the colon is special character in the Visual Studio flavour of RegEx and so needs to be escaped, but I was having trouble making a regular expression that optionally included a single colon.

I wanted to add a new parameter to a virtual function (that has been overriden in LOTS of classes).

So I wanted to find all the places where the function name appears in header files (where it is declared, i.e. without any scope resolution operator), and all the places it appears in the .cpp files following the name of the derived class and a scope resolution operator.

(I'd then do a separate find and replace to catch all the places where it's called).

I thought something like

FIND 
{\:?Foobar\( }{int FirstParamBeforeMyChange}

REPLACE WITH
\1char MyNewFirstParam, \2

would do the job. But I had no joy.

Can anybody tell me my mistake or how to do this?

Thanks, G.

Upvotes: 1

Views: 815

Answers (1)

Will A
Will A

Reputation: 24988

You need to use normal brackets () to enclose groups, not braces {}. You'll need to escape up the left-bracket you have as Foobar\(.

Upvotes: 1

Related Questions