Georgi Georgiev
Georgi Georgiev

Reputation: 3964

Netbeans Find and replace all strings

Is there any way to find all Strings in my source code regardless of their content. In other words I want to find everything that starts and ends with " . What I want to do afterwards is replace all found strings with someMethod(string). Edit:

I think I have not expressed myself clear. I want to find all strings no matter what the content between the " is and the "encapsulate" them. In your example syso("test") should become syso(somethod("test"))

Upvotes: 1

Views: 1808

Answers (2)

MaVRoSCy
MaVRoSCy

Reputation: 17839

You can use the Find In Project functionality using the Basic Wildcards options.

Then use the * wild card and search for syso(*) . This will return all occurrences of this method. Then manually you can replace the text you want.

Upvotes: 1

LPH
LPH

Reputation: 1295

CTRL+F - search for " and replace manually:

search for : the thing you want to replace(e.g. ") replace with: the thing you want to past instead (e.g.someMethod()) -> But look out for errors! think about replacing bevor you try it- because if you replace all " with somemethod, you have a lot of errors! Look at this example:

syso("test");
//---replace actoin: someMethod() instead of "
syso(someMethod()testsomeMethod())

-> best way is to make this kind of manipulations (in my oppinion): manually! Perhaps there are some Refactoring-Tools in Netbeans which could help you-but i don´t think that there is a "simple and easy" solution.

If you are searching for a solution for the whole project you are working on, go into the Edit menu-y there ou should find a item for "Replace in Project";

I hope i understood you right & could help a little!

Upvotes: 0

Related Questions