Visual Studio Code 搜索和替换为正则表达式 [英] Visual Studio Code Search and Replace with Regular Expressions

查看:66
本文介绍了Visual Studio Code 搜索和替换为正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Visual Studio Code 中使用搜索和替换"将 <h1>content</h1> 的每个实例更改为 #### content在使用正则表达式的文档中.

我怎样才能做到这一点?

解决方案

那么,你的目标是搜索和替换?
根据Visual Studio官方的键盘快捷键pdf,可以按Ctrl+ H 在 如果您想禁用代码,则只需将

放入搜索中,然后替换为 ####.

但是如果你想改用这个正则表达式,你可以在图标中启用它: 并使用正则表达式:

(.+?)<\/h1> 并替换为:#### $1.

正如 @tpartee 所建议的,如果您想了解更多信息,这里有一些关于 Visual Studio 引擎的更多信息:

I want to use "Search And Replace" in Visual Studio Code to change every instance of <h1>content</h1> to #### content within a document using a Regular Expression.

How can I accomplish that?

解决方案

So, your goal is to search and replace?
According to the Official Visual Studio's keyboard shotcuts pdf, you can press Ctrl + H on Windows and Linux, or ⌥⌘F on Mac to enable search and replace tool:

If you mean to disable the code, you just have to put <h1> in search, and replace to ####.

But if you want to use this regex instead, you may enable it in the icon: and use the regex: <h1>(.+?)<\/h1> and replace to: #### $1.

And as @tpartee suggested, here is some more information about Visual Studio's engine if you would like to learn more:

这篇关于Visual Studio Code 搜索和替换为正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆