VS Code Glob pattern optional single character

47 Views Asked by At

Using the VS Code "files to include" feature in search, I'd like to search for any Javascript file within a folder, including [.js, .ts, .jsx, .tsx] but not .json. I can already to this with 2 separate searches:

./theFolder/**/*.[tj]s, ./theFolder/**/*.[tj]sx

Is there a way to do it with just one, like it would be in Regex?

./theFolder/**/*.[tj]sx? // ? doesn't do that in vscode glob

Also see https://code.visualstudio.com/docs/editor/glob-patterns

1

There are 1 best solutions below

0
starball On BEST ANSWER

At the time of this writing, there's no single-optional-character matching feature.

But you can still make what you're doing less verbose by using {} to group conditions. Ex. ./theFolder/**/*.{[tj]s,[tj]sx}.

For docs, in addition to https://code.visualstudio.com/docs/editor/glob-patterns, see also https://code.visualstudio.com/docs/editor/codebasics#_advanced-search-options