CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-glob-to-regexp

tessl install tessl/npm-glob-to-regexp@0.4.0

Convert globs to regular expressions

Agent Success

Agent success rate when using this tile

100%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.15x

Baseline

Agent success rate without this tile

87%

task.mdevals/scenario-3/

File Name Validator

A utility for validating file names against specific patterns using simple wildcard matching.

Capabilities

Validates file names with single character wildcards

  • Given the pattern "log-?.txt", the filename "log-a.txt" is valid @test
  • Given the pattern "log-?.txt", the filename "log-1.txt" is valid @test
  • Given the pattern "log-?.txt", the filename "log-ab.txt" is invalid @test
  • Given the pattern "log-?.txt", the filename "log-.txt" is invalid @test

Validates file names with multiple single character wildcards

  • Given the pattern "data-??-??.csv", the filename "data-01-23.csv" is valid @test
  • Given the pattern "data-??-??.csv", the filename "data-ab-cd.csv" is valid @test
  • Given the pattern "data-??-??.csv", the filename "data-1-23.csv" is invalid @test

Validates file names with wildcards in different positions

  • Given the pattern "?.log", the filename "a.log" is valid @test
  • Given the pattern "test?.txt", the filename "test5.txt" is valid @test
  • Given the pattern "file-?-?.dat", the filename "file-x-y.dat" is valid @test

Implementation

@generates

API

/**
 * Validates a filename against a pattern with single-character wildcards.
 * The pattern uses '?' to match exactly one character.
 *
 * @param {string} filename - The filename to validate.
 * @param {string} pattern - The pattern to match against, using '?' for single-character wildcards.
 * @returns {boolean} True if the filename matches the pattern, false otherwise.
 */
function validateFilename(filename, pattern) {
  // IMPLEMENTATION HERE
}

module.exports = { validateFilename };

Dependencies { .dependencies }

glob-to-regexp { .dependency }

Converts glob patterns to regular expressions for pattern matching.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/glob-to-regexp@0.4.x
tile.json