Project

General

Profile

Actions

Feature #739

closed

Regexp#match with position

Added by viking (Jeremy Stephens) over 15 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
[ruby-core:19785]

Description

=begin
Regexp#=~ returns the position of the match. Regexp#match lets you search a string from a certain position. It would be great if Regexp#match also returned the position along with MatchData. In the current version (ruby-1.9.1-preview1), rb_reg_match_m already finds the position via reg_match_pos, but it doesn't return it. It would be trivial to stash the position somewhere in the return value.

I suppose you could either create an attribute reader in MatchData for position, or maybe Regexp#match could return an array of length 2, where the first element is the position, and the second is the MatchData object.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0