Home >Development Tools >VSCode >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
Examples of matching methods using regular expressions:
1) . — Matches any character
dot symbol . Used to match any character:
b.t
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
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"."
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!