{"id":"2d98f3012d3e4fc1","repo":"sharkdp/fd","slug":"note-you-can-search-for-literal-substrings-wi","errorCode":null,"errorMessage":"{}\n\nNote: You can search for literal substrings with '--fixed-strings' or literal strings with '--exact' options (instead of a regular expression). Alternatively, you can also use the '--glob' option to match on a glob pattern.","messagePattern":"(.+?)\n\nNote: You can search for literal substrings with '--fixed-strings' or literal strings with '--exact' options \\(instead of a regular expression\\)\\. Alternatively, you can also use the '--glob' option to match on a glob pattern\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":547,"sourceCode":"            .any(|pat| pattern_matches_strings_with_leading_dot(pat))\n    {\n        Err(anyhow!(\n            \"The pattern(s) seems to only match files with a leading dot, but hidden files are \\\n            filtered by default. Consider adding -H/--hidden to search hidden files as well \\\n            or adjust your search pattern(s).\"\n        ))\n    } else {\n        Ok(())\n    }\n}\n\nfn build_regex(pattern_regex: String, config: &Config) -> Result<regex::bytes::Regex> {\n    RegexBuilder::new(&pattern_regex)\n        .case_insensitive(!config.case_sensitive)\n        .dot_matches_new_line(true)\n        .build()\n        .map_err(|e| {\n            anyhow!(\n                \"{}\\n\\nNote: You can search for literal substrings with '--fixed-strings' \\\n                 or literal strings with '--exact' options (instead of a regular expression). \\\n                 Alternatively, you can \\\n                 also use the '--glob' option to match on a glob pattern.\",\n                e\n            )\n        })\n}\n","sourceCodeStart":529,"sourceCodeEnd":556,"githubUrl":"https://github.com/sharkdp/fd/blob/41532d114e2ba565fb5367d606c111b29b96450c/src/main.rs#L529-L556","documentation":"Thrown by build_regex in src/main.rs:547 when RegexBuilder::new(...).build() fails to compile the assembled pattern. fd wraps the underlying regex crate error and appends a hint pointing to --fixed-strings, --exact, or --glob for users who did not intend a regex. This is the catch-all for syntactically invalid regex input.","triggerScenarios":"Running 'fd [unclosed', 'fd *' (unguarded quantifier), 'fd (a|b', or any pattern the regex crate rejects.","commonSituations":"Typing a glob ('*.rs') expecting shell globbing; unbalanced brackets/parens; stray backslashes; legacy POSIX regex syntax.","solutions":["If you meant a glob, use --glob: 'fd --glob \"*.rs\"'.","If you meant a literal substring, use --fixed-strings: 'fd --fixed-strings \"$10\"'.","If you want a full-name exact match, use --exact: 'fd --exact foo.txt'.","Otherwise, fix the regex syntax (balance brackets/parens, escape metacharacters) and retry."],"exampleFix":"// before\nfd '*.rs'\n\n// after\nfd --glob '*.rs'","handlingStrategy":"validation","validationCode":"# pick the right matching mode before calling fd\nif printf '%s' \"$PAT\" | grep -Eq '[*?]'; then\n  fd --glob \"$PAT\" \"$@\"          # glob input\nelif [ -n \"$LITERAL\" ]; then\n  fd --fixed-strings \"$PAT\" \"$@\" # literal substring\nelse\n  # pre-validate the regex compiles\n  if ! printf '%s' \"$PAT\" | grep -Eq '\\\\|\\(|\\)|\\[|\\{|\\*|\\+'; then :; fi\n  fd \"$PAT\" \"$@\"\nfi","typeGuard":"use regex::{RegexBuilder, bytes::Regex};\nfn regex_compiles(pat: &str) -> bool {\n    RegexBuilder::new(pat).build().is_ok()\n}","tryCatchPattern":null,"preventionTips":["Use --glob for '*.ext' style patterns and --fixed-strings for literals.","Pre-validate user-supplied regex with the regex crate before passing to fd.","Balance brackets/parens and escape metacharacters when authoring regex."],"tags":["regex","search-pattern","parsing","user-guidance"],"analyzedSha":"41532d114e2ba565fb5367d606c111b29b96450c","analyzedAt":"2026-08-06T01:39:28.509Z","schemaVersion":2}