From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 02F61196003C for ; Fri, 26 Jun 2015 23:31:50 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 20603B5D875 for ; Fri, 26 Jun 2015 23:56:19 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id EE38197A82C for ; Fri, 26 Jun 2015 23:56:21 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BfV4FshqasBP for ; Fri, 26 Jun 2015 23:56:21 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id A9B1E97A827 for ; Fri, 26 Jun 2015 23:56:21 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 9773E952441 for ; Fri, 26 Jun 2015 23:56:18 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D95D012045C; Fri, 26 Jun 2015 23:56:16 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 574BA12003B for ; Fri, 26 Jun 2015 23:56:13 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=w+ysjhBAjc5S6KWq0nCa3aTD0r4=; b=FxcTmYF9IYNlHi4wX1 /b52aO871mSGaUm+Q2OYyRxzAERoYOH/Xnkj8FLDI8jZUU3nC7jHAE5pQZ+TVNeS ohUUJoYgcAFcikUgpYJlRnremKjgixVzDU8HlPvvsJ5u7hDfa2VCZ3V1uoLVeGfp 37+lmtzpOaE416e7IdwEgCu7o= Received: by filter0815p1mdw1.sendgrid.net with SMTP id filter0815p1mdw1.9786.558D67F2B 2015-06-26 14:55:46.484204016 +0000 UTC Received: from herokuapp.com (ec2-54-197-165-214.compute-1.amazonaws.com [54.197.165.214]) by ismtpd-004 (SG) with ESMTP id 14e305e0a70.1c8f.388eb8 for ; Fri, 26 Jun 2015 14:55:46 +0000 (UTC) Date: Fri, 26 Jun 2015 14:55:44 +0000 From: sawadatsuyoshi@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 44319 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11309 X-Redmine-Issue-Author: sawa X-Redmine-Sender: sawa X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS6Z3VOUg044SM39FK1wv1vSpqfQBvHcIco6wS qF0rusuzYDxzxq331nE58ErE8AAQC6htWdD2Vh+/a3TMVlgC6ui0C41Ky4kaV2BVtG4K1eT1dCkhAa L1iyVrO4sINt549YWUVxDAu9P6eGMonSt3/G X-SendGrid-Contentd-ID: {"test_id":"1435330548"} X-ML-Name: ruby-core X-Mail-Count: 69743 Subject: [ruby-core:69743] [Ruby trunk - Feature #11309] [Open] Iterator over string matches X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11309 has been reported by Tsuyoshi Sawada. ---------------------------------------- Feature #11309: Iterator over string matches https://bugs.ruby-lang.org/issues/11309 * Author: Tsuyoshi Sawada * Status: Open * Priority: Normal * Assignee: ---------------------------------------- This was hinted from a problem in stackoverflow (http://stackoverflow.com/questions/31074050/build-list-of-strings-containing-substrings-separated-by-an-from-a-string/31075511#31075511). Suppose there is a string: s = "a_b_c_d_e" To get an array of pre-matches that result from matching `s` with `"_"`, I can do this: a = [] s.scan("_"){a.push($`)} a # => ["a", "a_b", "a_b_c", "a_b_c_d"] But this looks too Perlish. I thought it would be nice if there is a method on `String` that creates an enumerator over matches so that I can do something like this: "a_b_c_d_e".some_method("_").with_object([]){|m, a| a.push(m.post_match)} # => ["a", "a_b", "a_b_c", "a_b_c_d"] where `m` is the last matchdata instance at that point. I believe such method would have wider application. -- https://bugs.ruby-lang.org/