Project

General

Profile

Actions

Feature #6802

open

String#scan should have equivalent yielding MatchData

Added by prijutme4ty (Ilya Vorontsov) over 11 years ago. Updated over 6 years ago.

Status:
Assigned
Target version:
-
[ruby-core:46801]

Description

Ruby should have method to obtain not an array of arrays but of MatchData objects. It can help in obtaining named groups:

pattern = /x: (?\d+) y:(?\d+)/
polygon = []
text.scan_for_pattern(pattern){|m| polygon << Point.new(m[:x], m[:y]) }

Not to break existing code we need unique name. Ideas? May be #each_match


Related issues 3 (1 open2 closed)

Related to Ruby master - Feature #5749: new method String#match_all neededAssignedmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Feature #5606: String#each_match(regexp)FeedbackActions
Related to Ruby master - Feature #12745: String#(g)sub(!) should pass a MatchData to the block, not a StringFeedbackmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0