ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: janko.marohnic@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:68675] [Ruby trunk - Bug #11014] [Open] String#partition doesn't return correct result on zero-width match
Date: Sun, 29 Mar 2015 14:51:57 +0000	[thread overview]
Message-ID: <redmine.issue-11014.20150329145156.83c85d356af35f8f@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11014.20150329145156@ruby-lang.org

Issue #11014 has been reported by Janko Marohnić.

----------------------------------------
Bug #11014: String#partition doesn't return correct result on zero-width match
https://bugs.ruby-lang.org/issues/11014

* Author: Janko Marohnić
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
First, to see how String#match works on my example:

~~~
match = "foo".match(/^=*/)
match.pre_match  #=> ""
match[0]         #=> ""
match.post_match #=> "foo"
~~~

Now, if I used String#partition instead of match, I'd expect to get `["", "", "foo"]` (pre_match, match, post_match). However

~~~
"foo".partition(/^=*/) #=> ["foo", "", ""]
~~~

String#rpartition returns the correct result (with the same regex).



-- 
https://bugs.ruby-lang.org/

       reply	other threads:[~2015-03-29 14:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11014.20150329145156@ruby-lang.org>
2015-03-29 14:51 ` janko.marohnic [this message]
2015-04-18 17:09 ` [ruby-core:68927] [Ruby trunk - Bug #11014] [Assigned] String#partition doesn't return correct result on zero-width match nobu
2020-01-07 10:04 ` [ruby-core:96701] [Ruby master Bug#11014] " sawadatsuyoshi
2020-01-07 13:23 ` [ruby-core:96702] " daniel
2020-01-14  2:49 ` [ruby-core:96830] " mame
2020-01-16  5:31 ` [ruby-core:96885] " akr
2020-01-16  5:44 ` [ruby-core:96887] " akr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.issue-11014.20150329145156.83c85d356af35f8f@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).