Home >Development Tools >VSCode >How to enter regular expressions for matching in vscode

How to enter regular expressions for matching in vscode

尚
Original
2020-01-09 11:50:4313911browse

How to enter regular expressions for matching in vscode

How to enter a regular expression in vscode for matching:

Use the shortcut key "Ctrl F" to bring up the search box

How to enter regular expressions for matching in vscode

Examples of matching methods using regular expressions:

1) . — Matches any character

dot symbol . Used to match any character:

b.t

How to enter regular expressions for matching in vscode

The above regular match matches "bot", `"bat" and any three-character word starting with b and ending with t. But if you want to search for the dot symbol, you need to escape it with \ , so the following regex only matches the exact text "b.t":

b\.t

How to enter regular expressions for matching in vscode

2) .* — means match anything

Here . means "any character", * means "this symbol repeats the previous content any number of times." Put them together (.*) means "any symbol repeated any number of times." For example, you can use it to find matches that start or end with some text. Suppose we have a javascript method like this:

loadScript(scriptName: string, pathToFile: string)

We want to find all calls to this method where pathToFile points to the folder "lua ” in any file. The following regular expression can be used:

loadScript.*lua

This means, "match all strings that start with "loadScript" and end with "lua"."

How to enter regular expressions for matching in vscode

Recommended related articles and tutorials: vscode tutorial

The above is the detailed content of How to enter regular expressions for matching in vscode. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn