rg --replace 'logger.error($1)' 'console\.error\((.*)\)' src/This is a preview only; combine with `sd`, `perl`, or editor tools for actual rewrites.
Preview replacements, search transformed files, and handle compressed or non-UTF8 data.
Use ripgrep to preview transformed output before applying changes with another tool.
rg --replace 'logger.error($1)' 'console\.error\((.*)\)' src/This is a preview only; combine with `sd`, `perl`, or editor tools for actual rewrites.
rg --replace '$2_$1' '(\w+)-(\w+)' sample.txtCapture-group replacement is great for exploring renames before making edits.
rg -o --replace '$1' 'name="([^"]+)"' template.htmlUseful for harvesting identifiers or values from structured text.
rg -P --replace '$1' '(?<=id=)\d+' data.txtThis works well when look-around is needed to isolate the match.
rg --line-number --no-heading 'TODO' . | fzfripgrep plus fzf is a classic workflow for interactive navigation and cleanup.
Search data that needs to be transformed before matching.
rg -z 'Exception' logs/`-z` lets ripgrep inspect gzip, xz, bzip2, lz4, brotli, and similar compressed inputs when supported.
rg --pre 'pdftotext -layout' 'invoice' docs/*.pdfPreprocessors are powerful when the raw file format is not plain text.
rg --pre 'pandoc -t plain' --pre-glob '*.docx' 'roadmap' docs/`--pre-glob` avoids paying a preprocessing cost for unrelated files.
tar -xOf backup.tar config/app.yml | rg 'database:'Sometimes a pipeline is simpler than a custom preprocessor.
rg -a 'sqlite' mystery.bin`-a` can be useful for generated files, dumps, or partially text-based formats.
Handle non-UTF8 files, BOMs, and line-ending differences.
rg --encoding utf-16le 'Version' report.txtThis is common with Windows exports and some vendor logs.
rg --encoding shift_jis 'エラー' app.logEncoding support helps when working across older systems or regional datasets.
rg 'TODO' README.txtripgrep handles CRLF line endings well by default, so no special flag is usually required.
rg -N --replace '$1' '"([^"]+)"' data.json`-N` is handy when line numbers would clutter preview output.
rg -l -0 'TODO' . | xargs -0 sed -n '1p'This is the shell-safe way to handle paths with spaces or newlines.