sterrab
sterrab

Reputation: 27

Structural Search and Replace WITHOUT Resharper

I don't have Resharper but after some research found that its search and replace functionality would easily solve the problem I am having. The problem is I have many lines in code that look like:

ex.foo

where foo varies and ex doesn't. I need to change them all to look like:

function(ex,"foo")

I could probably write some script for this specific case, but since I am going to be needing to do this type of replacement a lot in the future with different flavors, is there a good general purpose solution available outside of Resharper? The main problem is not recognizing the initial string, but saving foo so that I can use it in the replacement string. I'm not sure how to do that with, for instance, regex replacers.

Upvotes: 1

Views: 107

Answers (1)

KekuSemau
KekuSemau

Reputation: 6853

If notepad++ is an option for you, you could open all documents and "Replace in all opened documents" in one turn with this regex:

ex\.([a-zA-Z_]+)

Replace with

function(ex,"\1")

Upvotes: 1

Related Questions