根据搜索条件/正则表达式删除文件中的一行

时间:2022-09-25 16:43:14

I have a .csproj file which has entries like:

我有一个.csproj文件,其条目如下:

<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.

它们分散在整个文件中。

What I am looking for is to use Visual Studio(Preferred) or other tool to delete the entire line by Search/Replace.

我正在寻找的是使用Visual Studio(首选)或其他工具通过搜索/替换删除整行。

1 个解决方案

#1


1  

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.*?\/>

Working demo

工作演示

#1


1  

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.*?\/>

Working demo

工作演示