{"record":{"id":"3d07133da9f56085","repo":"stride3d/stride","slug":"can-t-match-pattern-that-uses","errorCode":null,"errorMessage":"Can't match pattern that uses '['","messagePattern":"Can't match pattern that uses '\\['","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Selectors/PathSelector.cs","lineNumber":102,"sourceCode":"            switch (c)\n            {\n                case '*':\n                    // Match everything (except '/')\n                    result.Append(\"[^/]*\");\n                    break;\n                case '?':\n                    // Match a single character (except '/')\n                    result.Append(\"[^/]\");\n                    break;\n                case '\\\\':\n                    // If not last character, escape next one\n                    if (++i < pattern.Length)\n                        c = pattern[i];\n\n                    // Default case (add character as is)\n                    goto default;\n                case '[':\n                   throw new NotImplementedException(\"Can't match pattern that uses '['\");\n                default:\n                    result.Append(Regex.Escape(c.ToString()));\n                    break;\n            }\n        }\n\n        // If there is no '/' at the end, it must either finish or have another path after\n        if (pattern.Length > 0 && pattern[^1] != '/')\n        {\n            result.Append(@\"($|/)\");\n        }\n        return result.ToString();\n    }\n}\n","sourceCodeStart":84,"sourceCodeEnd":117,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Selectors/PathSelector.cs#L84-L117","documentation":"PathSelector.TransformToRegex translates a glob-like selector pattern into a regular expression. The '[' character (character-class syntax) is not supported by this glob dialect, so encountering it throws NotImplementedException. The library explicitly refuses patterns it cannot translate rather than producing a wrong regex.","triggerScenarios":"Calling Select (e.g. new PathSelector(pattern).Select(...)) with a pattern containing '[', such as \"assets/[a-z]*.png\" or a bracketed directory name like \"lib[1]/\".","commonSituations":"Writing shell-style glob patterns assuming full glob support; selecting files whose actual names contain literal brackets (e.g. \"item[1].bin\"); porting glob expressions from other tools that support character classes.","solutions":["Rewrite the pattern using only '*', '?' and '**' constructs supported by PathSelector instead of character classes.","If a literal '[' must be matched, escape or restructure the pattern to avoid '[' (e.g. use '?' as a single-char wildcard: 'item?.bin').","Pre-filter the file list yourself with a real regex and skip PathSelector for character-class needs.","Check the file/path names: if assets genuinely contain brackets, rename them or handle selection outside the selector."],"exampleFix":"// before\nvar selector = new PathSelector(\"assets/[a-z]*.png\");\n\n// after\nvar selector = new PathSelector(\"assets/*.png\"); // filter case/detail with additional code","handlingStrategy":"validation","validationCode":"if (pattern.Contains('['))\n    throw new ArgumentException(\"PathSelector patterns do not support '[' character classes; use *, ?, or ** only.\", nameof(pattern));","typeGuard":null,"tryCatchPattern":"try { selector.Select(paths); }\ncatch (NotImplementedException) { /* fall back to Regex-based matching */ }","preventionTips":["Restrict patterns to *, ?, ** syntax","Escape or avoid '[' when matching literal bracket names","Use Regex directly when character classes are required","Add a pattern lint check before constructing PathSelector"],"tags":["glob","pattern","regex","not-implemented"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}