Visual Studio Code 搜索和替换为正则表达式 [英] Visual Studio Code Search and Replace with Regular Expressions
问题描述
我想在 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:
- Find and Replace Window (documentation)
- Quick Replace, Find and Replace Window (documentation)
- What flavor of Regex does Visual Studio Code use?
这篇关于Visual Studio Code 搜索和替换为正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!