vscode,

Wildcard regex in VSCode

Dec 24, 2022 · 1 min read · Post a comment

Nowadays, Visual Studio Code or just VSCode is the most commonly used IDE tool, period. For the newbies out there, just as me struggling to maintain a blog site, here’s a tip on how to do a wildcard search regex.

Prerequisites

  • VSCode

Solution

Step 1. Open VSCode and click on the Search (🔎) icon, on the top left (Command + Shift + F on macOS).

Step 2. Enable regex by clicking on the .* icon.

VSCode enable regex

Step 3. For the sake of an example, I’ll try to find every post that contains the tag docker. The key point is using .+?. So, it looks something like:

tags: \[.+?docker

VSCode wildcard regex example

\[.+? breakdown:

  • \[: escape special character [.
  • .: match any character.
  • +: one or more times.
  • ?: try to match this as few times as possible (helpful, as it won’t match past your quotes).

Conclusion

This could get you started regarding wildcard regex searching. About replacement, unfortunately, that depends on use cases. I’m sure you can find anything on the Internet. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.