简体   繁体   English

从搜索 PhpStorm 中排除字符串

[英]Exclude strings from search PhpStorm

This question might have an answer somewhere out there in the internet but I can't seem to find it.这个问题可能在互联网的某个地方有答案,但我似乎找不到。 Of course if you have a link to give me I will gladly accept it as an answer if it is what I am looking for.当然,如果你有一个链接给我,我很乐意接受它作为我正在寻找的答案。

Here goes: How can I exclude some strings from my global search?这里是:如何从全局搜索中排除一些字符串?

Basically I use the Ctrl + Shift + F to find all occurrences of a nameOfTheFile.php string to find all the patterns that call this file.基本上我使用Ctrl + Shift + F来查找所有出现的nameOfTheFile.php字符串来查找调用此文件的所有模式。 A not so very smart developer created multiple nameOfTheFile.php everywhere and so the path to include them always changes, I need something fix so I need to change every single call.一个不太聪明的开发人员在各处创建了多个nameOfTheFile.php ,因此包含它们的路径总是会发生变化,我需要修复一些东西,所以我需要更改每个调用。 There is a lot of calls => 1533 occurrences according to PhpStorm so doing them one by one is NOT an option.根据 PhpStorm,有很多调用 => 1533 次,因此不能一个接一个地进行。

So my plan is to write all the patterns down (there shouldn't be more than 50 so it is doable) and replace all of them later.所以我的计划是把所有的模式都写下来(不应该超过 50 个这样可行),然后再全部替换。 To do that I could use a filter to exclude the patterns that I have already found .为此,我可以使用过滤器来排除我已经找到的模式

At the moment the pattern list would be something like:目前,模式列表将类似于:

include_once("folderY/nameOfTheFile.php");
include_once(PATH . "folderY/nameOfTheFile.php");
include_once (PATH . "folderY/nameOfTheFile.php");
include_once ("../../../folderX/nameOfTheFile.php");
include_once ("../../folderX/nameOfTheFile.php");
include_once ("../folderX/nameOfTheFile.php");
require_once($settings['siteFilepath'] . "folderY/nameOfTheFile.php");

How can I exclude those strings from the search?如何从搜索中排除这些字符串? I thought of using a Regex but as I am not an expert (Junior Dev here:/) I can't really come up with it.我想过使用正则表达式,但由于我不是专家(这里是初级开发人员:/),我真的想不出它。 Also I would think that maybe there is something built in PhpStorm that could work better.此外,我认为 PhpStorm 中可能有一些可以更好地工作的东西。

Have I missed something?我错过了什么吗? Is there a Regex to help me?有正则表达式可以帮助我吗? Bonus point: if there is a Regex please explain how it works (remember I am far from being an expert).加分点:如果有正则表达式,请解释它是如何工作的(记住我远非专家)。

in PhpStorm go to replace all cntr+shift+R select 'Regex' option and enter在 PhpStorm go 替换所有 cntr+shift+R select 'Regex' 选项并输入

include_once.*nameOfTheFile\.php"\);

this will select offending entries for replacement这将 select 违规条目替换

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

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