Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ReSharper自定义模式,从字符串中提取文本_C#_Resharper - Fatal编程技术网

C# ReSharper自定义模式,从字符串中提取文本

C# ReSharper自定义模式,从字符串中提取文本,c#,resharper,C#,Resharper,我有很多代码,例如: Resources.SettingName.ResourceManager.GetString("Setting") 可以很容易地写为: SettingName.Setting 我一直试图在Resharper中编写一个自定义模式来实现这一点,但尚未成功。 谁能告诉我正确的模式是什么 ps:我使用resharper 6。您可以使用Visual Studio的快速查找和替换,使用正则表达式: 查找内容: Resources\.{.+}\.ResourceManager\.G

我有很多代码,例如:

Resources.SettingName.ResourceManager.GetString("Setting")
可以很容易地写为:

SettingName.Setting
我一直试图在Resharper中编写一个自定义模式来实现这一点,但尚未成功。 谁能告诉我正确的模式是什么


ps:我使用resharper 6。

您可以使用Visual Studio的快速查找和替换,使用正则表达式:

查找内容:

Resources\.{.+}\.ResourceManager\.GetString\(“{.+}”)

替换为:

\1.\2


这假设您的模式符合:
Resources.
{some setting name}
.ResourceManager.SetString(“
{some setting}
”)

我尝试了不同的占位符(参数、类型、表达式等),但都不起作用。我想您可以构建搜索模式,但不能构建替换模式,对吧?我终于采用了这个解决方案。还将其录制为宏,并将其绑定到键盘快捷键。替换位实际上必须是
\1.\2
。谢谢。@Vishalsah-我已经纠正了这一点,不知道为什么我认为他们是相反的,不管怎样,它帮助你实现了你的结果,这很好。