在IntelliJ中搜索特定情况的字符串。

huangapple go评论59阅读模式
英文:

Search for special case strings with IntelliJ

问题

我正在使用以下代码在项目的所有模块中搜索字符串:(.*?)

但是它会返回所有字符串,包括注释中的字符串。我想要的是只搜索特定赋值的字符串,例如通过 method.call(param1, param2, "param3"); 进行赋值的字符串。

英文:

I'm searching for String in all the modules of my project with: "(.*?)"

However it returns all the strings included those in annotations for example. In what way I can search for a string specific to assigned string values, i.e. through method.call(param1, param2, "param3"); only.

答案1

得分: 3

使用结构化搜索来完成这个操作:

  1. 打开结构化搜索窗口
  2. 在搜索模板中插入"$String$"
  3. 点击查找
  4. 在“查找”工具窗口中检查结果
    在IntelliJ中搜索特定情况的字符串。

如果您想要在对特定方法的调用中查找字符串文字:

  1. 将方法名添加到模板中,使搜索模板看起来像是 method.call($String$)
  2. $String$ 变量配置过滤器。这里可以使用正则表达式,例如 .*".*
    在IntelliJ中搜索特定情况的字符串。
英文:

Use structural search for that:

  1. Open structural search window
  2. Insert "$String$" into Search Template
  3. Click Find
  4. Check the results in "Find" tool window
    在IntelliJ中搜索特定情况的字符串。

If you want too find string literals in calls of an exact method:

  1. Add its name to the template, so search template will look like method.call($String$)
  2. Configure filter for $String$ variable. Regex could be used here, e.g. .*".*
    在IntelliJ中搜索特定情况的字符串。

huangapple
  • 本文由 发表于 2020年9月28日 06:51:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/64094033.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定