Project

General

Profile

Actions

Bug #18415

closed

String#rpartition is not sufficiently greedy compared to String#partition

Added by jdashton (J Daniel Ashton) over 2 years ago. Updated about 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.0preview1 (2021-11-09 master 5a3b2e6141) [x86_64-darwin21]
[ruby-core:106728]

Description

3.1.0-preview1 :043 > "...999...".partition /\d+/
 => ["...", "999", "..."] 
3.1.0-preview1 :044 > "...999...".rpartition /\d+/
 => ["...99", "9", "..."] 

Using the regex /\d+/, partition gives you all consecutive digits. However, rpartition gives only the last digit.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0