Convert globs to regular expressions
Overall
score
100%
Build a file filtering system that can match file paths against user-provided patterns with flexible matching options.
The system should provide a function createFilter(pattern, options) that:
caseSensitive (boolean, default: true): Whether matching should be case-sensitivematchAnywhere (boolean, default: false): Whether to match the pattern anywhere in the string (not just exact matches)The filter function should use the appropriate flags when converting the glob pattern to a regular expression:
caseSensitive is false, matching should be case-insensitivematchAnywhere is true, the pattern should match anywhere in the input string@generates
/**
* Creates a filter function based on a glob pattern and options
* @param {string} pattern - Glob pattern to match against
* @param {Object} options - Matching options
* @param {boolean} [options.caseSensitive=true] - Whether matching should be case-sensitive
* @param {boolean} [options.matchAnywhere=false] - Whether to match pattern anywhere in the string
* @returns {Function} Filter function that takes a string and returns boolean
*/
function createFilter(pattern, options) {
// Implementation here
}
module.exports = { createFilter };Provides glob pattern to regular expression conversion.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-glob-to-regexpdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9