多行查找和替换设置 属性 notepad++ 或 visual studio
Multi line Find and Replace get set property notepad++ or visual studio
我必须替换下面的表达式:-
public string Body =>
this._body;
收件人:
public string Body
{
get{return _body;}
set{_body = value;}
}
我正在使用 Notepad++ 查找和替换如下:-
查找正则表达式:=>\s*.*?;
替换正则表达式:{get{return\s*.*?;} set{\s*.*? = value;}}
这似乎不起作用,并且在没有 属性 名称的情况下错误地替换了它,如下所示:-
Public string Body {get{returns*.*?;} set{s*.*? = value;}}
我们如何更改表达式以使用 属性 名称获得所需的结果?
我们也可以在 Visual Studio
中做这样的事情吗?谢谢。
这适用于 VS2015 中的查找 (\bpublic\b[\s\r\n]*\bstring\b[\s\r\n]*\bBody\b([\s|\r\n]*)=>([\s\r\n]*)\bthis\b([\s\r\n]*)\b\._body\b)
我会使用查找并单击突出显示的区域并将其粘贴,具体取决于发生的替换次数。如果目录中的所有文件具有相同的文件类型 .ext
,您几乎最好编写一个小型控制台应用程序来遍历它们
我喜欢这种方法here where you could take it a step further and pass the directory and iterate through all the matching regx(*).cs files using Directory.EnumerateFiles()
这是使用 Npp 完成这项工作的方法:
- Ctrl+H
- 查找内容:
\b(public\s+string\s+Body)\s+=>\s+this\.(\w+);
- 替换为:
{get{returns ;} set{ = value;}}
- 全部替换
我必须替换下面的表达式:-
public string Body =>
this._body;
收件人:
public string Body
{
get{return _body;}
set{_body = value;}
}
我正在使用 Notepad++ 查找和替换如下:-
查找正则表达式:=>\s*.*?;
替换正则表达式:{get{return\s*.*?;} set{\s*.*? = value;}}
这似乎不起作用,并且在没有 属性 名称的情况下错误地替换了它,如下所示:-
Public string Body {get{returns*.*?;} set{s*.*? = value;}}
我们如何更改表达式以使用 属性 名称获得所需的结果?
我们也可以在 Visual Studio
中做这样的事情吗?谢谢。
这适用于 VS2015 中的查找 (\bpublic\b[\s\r\n]*\bstring\b[\s\r\n]*\bBody\b([\s|\r\n]*)=>([\s\r\n]*)\bthis\b([\s\r\n]*)\b\._body\b)
我会使用查找并单击突出显示的区域并将其粘贴,具体取决于发生的替换次数。如果目录中的所有文件具有相同的文件类型 .ext
,您几乎最好编写一个小型控制台应用程序来遍历它们我喜欢这种方法here where you could take it a step further and pass the directory and iterate through all the matching regx(*).cs files using Directory.EnumerateFiles()
这是使用 Npp 完成这项工作的方法:
- Ctrl+H
- 查找内容:
\b(public\s+string\s+Body)\s+=>\s+this\.(\w+);
- 替换为:
{get{returns ;} set{ = value;}}
- 全部替换