# Path Matching
Glob patterns for matching tool names and file paths.
Tool Patterns
| Pattern | Matches | Doesn't Match |
|---|---|---|
| * | All tools | - |
| file_* | file_read, file_write | read_file |
| *_read | file_read, db_read | read_file |
Path Patterns
| Pattern | Matches | Doesn't Match |
|---|---|---|
| /data/* | /data/file.txt | /data/sub/file.txt |
| /data/** | /data/a/b/c.txt | /other/file.txt |
| **/*.json | /a/b/data.json | file.txt |
Using Path Matcher
typescript
1import { PathMatcher } from '@solongate/sdk';23const matcher = new PathMatcher();45// Single pattern matching6matcher.match('/data/**', '/data/sub/file.txt'); // true7matcher.match('/data/*', '/data/sub/file.txt'); // false89// Multiple patterns (any match)10matcher.matchAny(['/data/**', '/tmp/**'], '/data/file.txt'); // true1112// Multiple patterns (all must match)13matcher.matchAll(['**/*.txt', '/data/**'], '/data/file.txt'); // true1415// Extract matched parts16const result = matcher.extract('/users/:id/files/*', '/users/123/files/doc.txt');17// { id: '123', '*': 'doc.txt' }
Pattern Syntax Reference
| Syntax | Description |
|---|---|
| * | Matches any characters except / |
| ** | Matches any characters including / |
| ? | Matches exactly one character |
| [abc] | Matches any character in brackets |
| [a-z] | Matches character range |
| :param | Named parameter capture |