根据搜索条件/正则表达式删除文件中的一行 [英] Delete a line in file based on search criteria / Regex
本文介绍了根据搜索条件/正则表达式删除文件中的一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 .csproj 文件,其中包含以下条目:
I have a .csproj file which has entries like:
<Content Include="somepath1\somedir2\dir3\Thumbs.db" />
<Content Include="newpath\somedir2\Thumbs.db" />
<Content Include="anotherpath\somedir1\dir3\dir4\Thumbs.db" />
它们分散在整个文件中.
They are scattered all over the file.
我正在寻找的是使用 Visual Studio(Preferred) 或其他工具通过搜索/替换删除整行.
What I am looking for is to use Visual Studio(Preferred) or other tool to delete the entire line by Search/Replace.
推荐答案
如果你想删除所有包含的内容,你可以使用一个简单的正则表达式,如下所示:
If you want to remove all the content include, you can use a simple regex like this:
<Content Include=.*?\/>
另一方面,如果你想删除拇指,那么你可以使用
On the other hand, if you want to remove the thumbs then you can use
<Content Include=".*?Thumbs.db.*?\/>
这篇关于根据搜索条件/正则表达式删除文件中的一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文