Skip to content

Replace gsub with rstrip#1095

Merged
tompng merged 1 commit into
ruby:masterfrom
Maumagnaguagno:rstrip
May 6, 2025
Merged

Replace gsub with rstrip#1095
tompng merged 1 commit into
ruby:masterfrom
Maumagnaguagno:rstrip

Conversation

@Maumagnaguagno

Copy link
Copy Markdown
Contributor

The regular expression /\s*\z/ matches any whitespace characters at end of string, which means only one match is possible with gsub, replacing it with an empty string. The same can be achieved by String#rstrip.

The regular expression ``/\s*\z/`` matches any whitespace characters at end of string, which means only one match is possible with ``gsub``, replacing it with an empty string. The same can be achieved by ``String#rstrip``.
@tompng

tompng commented May 6, 2025

Copy link
Copy Markdown
Member

Looks good, thank you!

@tompng tompng merged commit 6a519e9 into ruby:master May 6, 2025
@Maumagnaguagno Maumagnaguagno deleted the rstrip branch May 6, 2025 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants