简体   繁体   English

Netbeans查找并替换所有字符串

[英]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: 换句话说,我想找到所有以""开头和结尾的内容。之后,我要做的就是将所有找到的字符串替换为someMethod(string)编辑:

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")) 我想找到所有字符串,无论"是”和“封装”它们之间的内容是什么。在您的示例中, syso("test")应该变成syso(somethod("test"))

You can use the Find In Project functionality using the Basic Wildcards options. 您可以使用“ Basic Wildcards选项使用“ Find In Project功能。

Then use the * wild card and search for syso(*) . 然后使用*通配符并搜索syso(*) This will return all occurrences of this method. 这将返回此方法的所有实例。 Then manually you can replace the text you want. 然后,您可以手动替换所需的文本。

CTRL+F - search for " and replace manually: CTRL + F-搜索"并手动替换:

search for : the thing you want to replace(eg ") replace with: the thing you want to past instead (egsomeMethod()) -> 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! 搜索:您要替换的东西(例如“”替换为:您要粘贴的东西(egsomeMethod())->但是要注意错误!考虑替换,请尝试一下-因为如果您替换所有“使用某种方法,您会遇到很多错误! 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. 也许Netbeans中有一些重构工具可以为您提供帮助-但我认为没有“简单易用”的解决方案。

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! 希望我能正确理解您并能有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM