Project

General

Profile

Actions

Feature #13110

closed

Byte-based operations for String

Added by shugo (Shugo Maeda) about 7 years ago. Updated about 2 years ago.

Status:
Closed
Target version:
-
[ruby-core:78995]

Description

How about to add byte-based operations for String?

s = "あああいいいあああ"
p s.byteindex(/ああ/, 4) #=> 18
x, y = Regexp.last_match.byteoffset(0) #=> [18, 24]
s.bytesplice(x...y, "おおお")
p s #=> "あああいいいおおおあ"

Files

byteindex.diff (2.83 KB) byteindex.diff PoC code for String#byteindex and Regexp#byteoffset shugo (Shugo Maeda), 01/06/2017 04:03 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0