зеркало из https://github.com/github/ruby.git
338eb0065b
unmached capture (https://github.com/ruby/strscan/pull/72) fix https://github.com/ruby/strscan/issues/70 If there is no substring matching the group (s[3]), the behavior is different. If there is no substring matching the group, the corresponding element (s[3]) should be nil. ``` s = StringScanner.new('foobarbaz') #=> #<StringScanner 0/9 @ "fooba..."> s.scan /(foo)(bar)(BAZ)?/ #=> "foobar" s[0] #=> "foobar" s[1] #=> "foo" s[2] #=> "bar" s[3] #=> nil s.captures #=> ["foo", "bar", ""] s.captures.compact #=> ["foo", "bar", ""] ``` ``` s = StringScanner.new('foobarbaz') #=> #<StringScanner 0/9 @ "fooba..."> s.scan /(foo)(bar)(BAZ)?/ #=> "foobar" s[0] #=> "foobar" s[1] #=> "foo" s[2] #=> "bar" s[3] #=> nil s.captures #=> ["foo", "bar", nil] s.captures.compact #=> ["foo", "bar"] ``` https://docs.ruby-lang.org/ja/latest/method/MatchData/i/captures.html ``` /(foo)(bar)(BAZ)?/ =~ "foobarbaz" #=> 0 $~.to_a #=> ["foobar", "foo", "bar", nil] $~.captures #=> ["foo", "bar", nil] $~.captures.compact #=> ["foo", "bar"] ``` * StringScanner#captures is not yet documented. https://docs.ruby-lang.org/ja/latest/class/StringScanner.html https://github.com/ruby/strscan/commit/1fbfdd3c6f |
||
---|---|---|
.. | ||
-test- | ||
bigdecimal | ||
cgi/escape | ||
continuation | ||
coverage | ||
date | ||
digest | ||
erb/escape | ||
etc | ||
fcntl | ||
fiddle | ||
io | ||
json | ||
monitor | ||
nkf | ||
objspace | ||
openssl | ||
pathname | ||
psych | ||
pty | ||
rbconfig/sizeof | ||
ripper | ||
rubyvm | ||
socket | ||
stringio | ||
strscan | ||
syslog | ||
win32 | ||
win32ole | ||
zlib | ||
.document | ||
Setup | ||
Setup.atheos | ||
Setup.nt | ||
extmk.rb |