Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/19.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.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
Regex VisualStudio中的正则表达式以删除区域和内容_Regex_Visual Studio - Fatal编程技术网

Regex VisualStudio中的正则表达式以删除区域和内容

Regex VisualStudio中的正则表达式以删除区域和内容,regex,visual-studio,Regex,Visual Studio,我正在使用Visual Studio 2010搜索和替换。 我想搜索文件中的所有区域,并将其与内容一起删除 比如说, #region Blah These are the contents of Blah Line 2 of blah is even more interesting blah blah blah blah......... #endregion 我想删除上面的所有内容。使用此选项: \#region[\s\S]*?\#endregion.*$ 使用多行和全局修改器。示例

我正在使用Visual Studio 2010搜索和替换。 我想搜索文件中的所有区域,并将其与内容一起删除

比如说,

#region Blah

These are the contents of Blah
Line 2 of blah is even more interesting
blah blah blah blah.........

#endregion
我想删除上面的所有内容。

使用此选项:

\#region[\s\S]*?\#endregion.*$

使用多行和全局修改器。示例:

这不起作用。我假设VisualStudio搜索和替换正则表达式略有不同。可能,是的--对它的搜索/替换功能一点也不熟悉,抱歉。看来需要转义hashtag。所以这个\#region(.|\n)*\#endregion.*$可以工作,但不幸的是,它拾取了我文件中的第一个#region,并且直到文件中的最后一个#endregion才停止。我希望它能单独拾取它们。使用非贪婪匹配,然后使用
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\?我认为它更简洁,语义更准确PI使用VS2010并使用了他们的正则表达式引擎。您是否阅读了有关其语法的帮助文档?如果不是的话,这是一个很好的开始,因为为此创建正则表达式可能非常简单。