Escape RegExp special characters in strings for safe use in regular expressions
Overall
score
100%
Evaluation — 100%
↑ 1.00xAgent success when using this tile
{
"context": "This criteria evaluates the engineer's ability to use the escape-string-regexp package, specifically focusing on proper usage of the escapeStringRegexp function to safely handle hyphen characters and special characters in regular expressions for Unicode-compatible text search.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Import escape-string-regexp",
"description": "Successfully imports the escapeStringRegexp function from the 'escape-string-regexp' package using the correct import syntax (e.g., import escapeStringRegexp from 'escape-string-regexp')",
"max_score": 15
},
{
"name": "Use escapeStringRegexp",
"description": "Calls the escapeStringRegexp function to escape the search term before using it in a regular expression pattern",
"max_score": 25
},
{
"name": "Construct RegExp correctly",
"description": "Creates RegExp objects using the escaped string from escapeStringRegexp (e.g., new RegExp(escapeStringRegexp(searchTerm)) or similar pattern)",
"max_score": 20
},
{
"name": "Handle case-insensitive search",
"description": "Implements case-insensitive search by passing appropriate flags (e.g., 'i') to the RegExp constructor when the caseInsensitive parameter is true",
"max_score": 15
},
{
"name": "Test hyphen handling",
"description": "All test cases with hyphens (2023-12-31, foo-bar, UTF-8, multi-word-phrase, X-Ray) pass correctly, demonstrating proper escaping that prevents hyphens from being interpreted as character class ranges",
"max_score": 15
},
{
"name": "Implement both functions",
"description": "Both searchText and findAllMatches functions are implemented according to the API specification, correctly using escapeStringRegexp in their implementations",
"max_score": 10
}
]
}Install with Tessl CLI
npx tessl i tessl/npm-escape-string-regexp@5.0.0