Instead of error-prone regular expressions, you can use types to filter files based on tags discovered by the identify library (e.g., python, javascript, text, binary, executable).
types: An array of tags. All tags in the list must match (AND logic).types_or: An array of tags. Any tag in the list can match (OR logic).types, types_or, and files are evaluated together with AND logic.
If you need to use a hook on files that don't match its default type, you must override the types setting.
To see the tags for a specific file, use the identify-cli tool.
# Match files that are in foo/ AND are either python or text
files: ^foo/
types: [file, python]
# Match files in foo/ that are javascript, jsx, ts, OR tsx
files: ^foo/
types_or: [javascript, jsx, ts, tsx]
# Overriding default types (e.g., using check-json on non-json files)
- id: check-json
types: [file] # override `types: [json]`
files: \.(json|myext)$