Skip to content

mruby-regexp: list String#sub! and #gsub! in the README - #7076

Merged
matz merged 1 commit into
mruby:masterfrom
takumin:regexp-readme-sub-bang
Aug 10, 2026
Merged

mruby-regexp: list String#sub! and #gsub! in the README#7076
matz merged 1 commit into
mruby:masterfrom
takumin:regexp-readme-sub-bang

Conversation

@takumin

@takumin takumin commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The Ruby API section of mrbgems/mruby-regexp/README.md lists the String
methods that take a Regexp in this gem. The bang pair added in b4f41f8
(#7061) never reached that list, so the README still reads as though only
sub and gsub accept a pattern.

s = "hello world"
s.sub!(/o/, "0")   # => "hell0 world", documented nowhere

Documentation only, no behavior change. The four spellings go next to the
non-bang pair they mirror, and the comment states the one thing the bang form
differs on: self when a substitution took place and nil when the pattern did
not match, which is what sub! answers there today.

Summary by CodeRabbit

  • Documentation
    • Added documentation for the mutating String replacement methods sub! and gsub!.
    • Clarified supported replacement-string and block forms, along with return behavior.

The `Ruby API` section of the gem's README lists the String methods that take
a Regexp here, and the bang pair added in b4f41f8 never reached that list,
so the README still reads as though only `sub` and `gsub` accept a pattern.

```ruby
s = "hello world"
s.sub!(/o/, "0")   # => "hell0 world", documented nowhere
```

Add the four spellings next to the non-bang pair they mirror, and state the
return value the bang form differs on: self when a substitution took place and
nil when the pattern did not match.
@takumin
takumin requested a review from matz as a code owner August 10, 2026 13:00
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 473e5ccb-3c30-4f03-b327-9f5248f9dfab

📥 Commits

Reviewing files that changed from the base of the PR and between b7e292e and 07f1599.

📒 Files selected for processing (1)
  • mrbgems/mruby-regexp/README.md

📝 Walkthrough

Walkthrough

The mruby-regexp README now documents String#sub! and String#gsub!, including replacement-string and block forms and their self or nil return behavior.

Changes

Regexp documentation

Layer / File(s) Summary
Mutating replacement method examples
mrbgems/mruby-regexp/README.md
Adds examples for String#sub! and String#gsub! with replacement strings and blocks. Documents self on a match and nil when no match exists.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

  • mruby/mruby#6989: Changes argument and block handling for String#sub and String#gsub.
  • mruby/mruby#7061: Implements the behavior documented by this PR for String#sub! and String#gsub!.

Suggested labels: mrbgems

Suggested reviewers: matz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the README update that documents String#sub! and String#gsub!.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@matz
matz merged commit beefa1e into mruby:master Aug 10, 2026
21 checks passed
@takumin
takumin deleted the regexp-readme-sub-bang branch August 10, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants