I have loads of instances of code like:
throw CODBCException("Error!",GetHENV(),GetHDBC());
throw CODBCException(Msg,GetHENV(),GetHDBC());
I want to replace each with a utility method:
throwException("Error!") or throwException(Msg)
Is this something Visual C++ search/replace can do using a regex? I never used this feature before and I don’t really know regex well either, but it would be pretty neat.
I’m only interested what comes up to the first comma e.g. throw CODBCException("Error!", so really I’m searching to replace throw CODBCException(X,...) with throwException(X)
It depends on how generic you want the regex to be (eg. how close to the string examples you gave does the match have to be), but you use this for the find option:
and then use this for the replace with option:
In general, you can use the curly braces to specify a back-reference you want to replace, and use “\1”, etc. to replace them.
Edit: Per updated question description, the following should be used for the find option: