{"id":13437309,"url":"https://github.com/your-tools/ruplacer","last_synced_at":"2025-05-14T14:08:24.750Z","repository":{"id":38315464,"uuid":"109975270","full_name":"your-tools/ruplacer","owner":"your-tools","description":"Find and replace text in source files","archived":false,"fork":false,"pushed_at":"2025-03-11T10:19:59.000Z","size":248,"stargazers_count":470,"open_issues_count":12,"forks_count":24,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-12T14:01:09.894Z","etag":null,"topics":["awk","command-line","grep","replace","rust","sed"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/your-tools.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-11-08T12:49:30.000Z","updated_at":"2025-05-10T08:34:05.000Z","dependencies_parsed_at":"2022-08-17T15:45:20.835Z","dependency_job_id":"1b4219ae-85f0-4712-9a02-d94518f08210","html_url":"https://github.com/your-tools/ruplacer","commit_stats":{"total_commits":210,"total_committers":16,"mean_commits":13.125,"dds":0.5047619047619047,"last_synced_commit":"add652f45cc3d88fd6f1e151579fa084b74593e5"},"previous_names":["tankerhq/ruplacer"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/your-tools%2Fruplacer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/your-tools%2Fruplacer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/your-tools%2Fruplacer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/your-tools%2Fruplacer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/your-tools","download_url":"https://codeload.github.com/your-tools/ruplacer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253754219,"owners_count":21958842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["awk","command-line","grep","replace","rust","sed"],"created_at":"2024-07-31T03:00:55.864Z","updated_at":"2025-05-14T14:08:24.729Z","avatar_url":"https://github.com/your-tools.png","language":"Rust","readme":"[![crates.io image](https://img.shields.io/crates/v/ruplacer.svg)](https://crates.io/crates/ruplacer)\n\n# Ruplacer\n\nFind and replace text in source files:\n\n```\n$ ruplacer old new src/\nPatching src/a_dir/sub/foo.txt\n-- old is everywhere, old is old\n++ new is everywhere, new is new\n\nPatching src/top.txt\n-- old is nice\n++ new is nice\n\nWould perform 2 replacements on 2 matching files.\nRe-run ruplacer with --go to write these changes to disk\n```\n\n## Note\n\nThis project was originally hosted on the\n[TankerHQ](https://github.com/TankerHQ) GitHub organization, which was\nmy employer from 2016 to 2021. They kindly agreed to give me back ownership\nof this project. Thanks!\n\n\n## Installing with cargo\n\nInstall `rust` and `cargo`, for example with [rustup](https://rustup.rs/).\n\nThen run:\n\n```\ncargo install ruplacer\n```\n\n## Alternative installation methods\n\n* Pre-compiled binaries for Linux, macOS, and Windows are available as [assets of the latest release](\nhttps://github.com/your-tools/ruplacer/releases/tag/v0.10.0).\n\n* `ruplacer` can also be installed from `homebrew`:\n\n```\nbrew install TankerHQ/homebrew-repo/ruplacer\n```\n\n* `ruplacer` is also on [the Arch Linux User Repository](https://aur.archlinux.org/packages/ruplacer/)\n\n## Basic usage\n\n```\nruplacer pattern replacement [path]\n```\n\nIf the path is not given, it defaults to the current working directory.\n\nRuplacer will then walk through every file in `\u003cpath\u003e` while honoring `.gitignore` files found on the way.\n\nBinary files and text files containing non-UTF8 characters will be skipped. Then for\nevery remaining file, it will read the contents, replace all lines matching the\npattern by the replacement, and print the difference.\n\nIf you are OK with the replacements, re-run `ruplacer` with the `--go` option to actually write the changes to disk.\n\n## Regex\n\nBy default, `pattern` will be compiled into a [Rust regex](https://docs.rs/regex/1.0.5/regex/).\n\nNote that it's slightly different from Perl-style regular expressions. Also, you must use `$1`, `$2` to reference\ngroups captured from `pattern` inside `replacement`.\n\nFor instance, this replaces 'last, first' by 'first last':\n\n```\nruplacer '(\\w+), (\\w+)' '$2 $1'\n```\n\n(note the use of single quotes to avoid any processing by the shell)\n\n\nIf you don't want the pattern to be used as a regex, use the `--no-regex` command line flag.\n\nThis makes it possible to look for special characters without escaping them:\n\n```\n# This is a regex that matches the letter a\n# or the letter o\n$ ruplacer '(a|o)' u\n- tata toto\n+ tutu tutu\n- (a|o)\n+ (u|u)\n\n# This is the literal string: '(a|o)'\n$ ruplacer --no-regex '(a|o)' u\n# or\n$ ruplacer '\\(a\\|o|)' u\n- (a|o)\n+ u\n\n```\n\n\n## Preserving case while replacing\n\nRuplacer has a `--preserve-case` option which works across a variety of case styles (lower case, snake case, and so on):\n\n```\n$ ruplacer --preserve-case foo_bar spam_eggs\nPatching src/foo.txt\n-- foo_bar, FooBar, and FOO_BAR!\n++ spam_eggs, SpamEggs, and SPAM_EGGS!\n```\n\n## Filter files by type or glob patterns\n\nInspired by [ripgrep](https://github.com/BurntSushi/ripgrep), you can also select or ignore certain \"file types\" or glob patterns:\n\n```\n# Select only C++ files\n$ ruplacer old new --type cpp\n# Select only *.foo files\n$ ruplacer old new --type *.foo\n# Select only files that match foo*bar.c\n$ ruplacer old new --type foo*bar.c\n\n# Ignore all js files\n$ ruplacer old new --type-not js\n# Ignore all *.bar files\n$ ruplacer old new --type-not *.bar\n# Ignore all files that match foo*bar.c\n$ ruplacer old new --type-not foo*bar.c\n```\n\nEach \"file type\" is just a list of glob pattern. For instance: the `cpp` file type matches `*.C`, `*.H`, `*.cc`, `*.cpp` and so on ...\n\nYou can see the whole list by using `ruplacer --type-list`.\n","funding_links":[],"categories":["应用","Applications","应用程序 Applications","Rust","命令行工具","rust","File"],"sub_categories":["Text processing","文本处理 Text processing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyour-tools%2Fruplacer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyour-tools%2Fruplacer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyour-tools%2Fruplacer/lists"}