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 how well an engineer uses the escape-string-regexp package to safely escape special characters for regex usage, particularly focusing on character class and mid-pattern insertion safety with proper hyphen handling.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Uses escape-string-regexp",
"description": "The solution imports and uses the escape-string-regexp package (or escapeStringRegexp function) to escape special regex characters",
"max_score": 25
},
{
"name": "Escapes in findLiteralPattern",
"description": "The findLiteralPattern function correctly uses escapeStringRegexp to escape the search term before constructing a regex pattern",
"max_score": 20
},
{
"name": "Constructs valid regex",
"description": "The solution correctly constructs a RegExp object using the escaped string and uses it to test against the target text",
"max_score": 15
},
{
"name": "Handles Unicode correctly",
"description": "The solution properly handles Unicode characters including emojis, ensuring they are preserved during escaping and matching",
"max_score": 10
},
{
"name": "Escapes in buildCharacterClassPattern",
"description": "The buildCharacterClassPattern function uses escapeStringRegexp to escape each pattern string in the array",
"max_score": 15
},
{
"name": "Handles hyphen escaping",
"description": "The solution recognizes that escapeStringRegexp uses \\x2d for hyphens, which ensures safety in character class contexts by preventing unintended range creation",
"max_score": 15
}
]
}Install with Tessl CLI
npx tessl i tessl/npm-escape-string-regexp@5.0.0