MediumPro challengePythonJavaScriptTypeScript

Simple Glob Match

Node.jsFilesPatterns

Match a path against a glob pattern. Support:

  • * matches any sequence except /.
  • ? matches any single char except /.
  • ** matches any sequence including /.

solve('src/*.ts', 'src/index.ts')true.

Sample tests

Test #1* matches filename
Input: ["src/*.ts","src/index.ts"]
Output: true
Test #2* does NOT cross /
Input: ["src/*.ts","src/sub/index.ts"]
Output: false
Test #3** crosses /
Input: ["src/**/*.ts","src/sub/deep/index.ts"]
Output: true
Test #4Top-level
Input: ["*.js","a.js"]
Output: true
Test #5? wildcard
Input: ["file?.txt","file1.txt"]
Output: true