[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>
Currently, ruby/spec is maintained mostly by individuals and enjoys the
13 messages
2016/12/13
[#78963] Re: ruby/spec needs help from CRuby committers
— Urabe Shyouhei <shyouhei@...>
2017/01/04
I did ask attendees of last developer meeting to join this
[#78642] Re: ruby/spec needs help from CRuby committers
— Eric Wong <normalperson@...>
2016/12/14
Benoit Daloze <eregontp@gmail.com> wrote:
[ruby-core:78903] [Ruby trunk Bug#13082] Regex match from position behavior with start of line/string special character
From:
me@...
Date:
2016-12-29 08:46:37 UTC
List:
ruby-core #78903
Issue #13082 has been updated by Vincent Woo. Thanks, I didn't know about \G! It's a little hard to understand in this situation, do you think it might be helpful to add to the doc on matching with position? "\G - Matches point where last match finished" ---------------------------------------- Bug #13082: Regex match from position behavior with start of line/string special character https://bugs.ruby-lang.org/issues/13082#change-62314 * Author: Vincent Woo * Status: Rejected * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16] * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- Hello, Apologies in advance if this question was addressed already, I could not find any information on it. Regexp#match [provides this behavior](https://ruby-doc.org/core-2.4.0/Regexp.html#method-i-match): > If the second parameter (pos) is present, it specifies the position in the string to begin the search. So, if you run: `/test/.match "a test", 2` it will return a match. This becomes an issue when you try to write a regex to match "if the pattern begins at the specified point in the string". `/^test/.match "a test", 2` Does not return a match. Using `\A` does not work either. It's an open question whether this *should* work, but I think it should. I would expect calling match with a position to treat the string passed in as essentially truncated up to that point. I should add that the reason I want it to work this way is that queries like `/test/.match "a longer test", 2` will return a match. My real goal is to find if `/test/` *starts* at position 2, so I do need the special line/string start character. What do you think? Cheers, Vincent -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>