/(.)(.)/.match("ab").select {|v| true } is empty

e$B0J2<$N$h$&$K!"e(BMatchData#select e$B$G%V%m%C%/$,>o$K??$J$N$K7k2Le(B
e$B$,6u$K$J$k$N$OJQ$G$O$J$$$G$7$g$&$+!#e(B

% ./ruby -ve ‘p(/(.)(.)/.match(“ab”).select {|v| true })’
ruby 1.9.0 (2008-05-01 revision 16250) [i686-linux]
[]

e$B%^%K%e%"%k$K$Oe(B self.to_a.select { … } e$B$HF1$8$H=q$$$F$"$j$^e(B
e$B$9$,!"$=$&$9$k$H6u$G$O$J$/$J$j$^$9!#e(B

% ./ruby -ve ‘p(/(.)(.)/.match(“ab”).to_a.select {|v| true })’
ruby 1.9.0 (2008-05-01 revision 16250) [i686-linux]
[“ab”, “a”, “b”]

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34556] /(.)(.)/.match(“ab”).select {|v| true }
is empty”
on Thu, 1 May 2008 16:20:53 +0900, Tanaka A. [email protected]
writes:

|e$B0J2<$N$h$&$K!"e(BMatchData#select e$B$G%V%m%C%/$,>o$K??$J$N$K7k2Le(B
|e$B$,6u$K$J$k$N$OJQ$G$O$J$$$G$7$g$&$+!#e(B

MatchData#selecte$B$Oe(Bvalues_ate$B$Ne(Baliase$B$G$9$+$ie(BEnumerablee$B7O$Ne(B
selecte$B$H$O5sF0$,0[$J$j$^$9!#La$jCM$O;XDj$7$?0z?t$r%$%s%G%C%/e(B
e$B%9$H$9$kCM$rMWAG$H$9$kG[Ns$G$9!#e(BRDoce$B$K$O0J2<$N$h$&$K$"$j$^$9!#e(B

 mtch.values_at([index]*)   => array
 mtch.select([index]*)   => array

Uses each index to access the matching values, returning an
array of
the corresponding matches.

 m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
 m.to_a                  #=> ["HX1138", "H", "X", "113", "8"]
 m.values_at(0, 2, -2)   #=> ["HX1138", "X", "113"]

|e$B%^%K%e%"%k$K$Oe(B self.to_a.select { … } e$B$HF1$8$H=q$$$F$"$j$^e(B
|e$B$9$,!"$=$&$9$k$H6u$G$O$J$/$J$j$^$9!#e(B

e$B$G$9$+$i!"$3$l$O!V%^%K%e%"%[email protected]$H;W$$$^$9!#D{@5$7$?e(B
e$BJ}$,$h$$$G$7$g$&$M!#e(B

e$B$=$l$O$=$l$H$7$F!"e(Bselecte$B$H$$$&L>[email protected]$_$d$9$$$N$G!"e(B

  • e$B:o=|e(B or e$B2~L>$9$ke(B
  • e$B0z?t$,L5$$e(B and/or e$B%V%m%C%/$,M?$($i$l$F$$$k>[email protected]*e(B
    e$B$K%(%i!<$^$?$O7Y9p$K$9$k!#e(B

e$B$J$I$NBP:[email protected]$H;W$$$^$9!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

In article [email protected],
Yukihiro M. [email protected] writes:

MatchData#selecte$B$Oe(Bvalues_ate$B$Ne(Baliase$B$G$9$+$ie(BEnumerablee$B7O$Ne(B
selecte$B$H$O5sF0$,0[$J$j$^$9!#La$jCM$O;XDj$7$?0z?t$r%$%s%G%C%/e(B
e$B%9$H$9$kCM$rMWAG$H$9$kG[Ns$G$9!#e(BRDoce$B$K$O0J2<$N$h$&$K$"$j$^$9!#e(B

e$B$*$)!"e(Brdoc e$B$OFI$s$G$^$;$s$G$7$?!#e(B

e$B$7$+$7!"[email protected]@$Oe(B 1.8.1 e$B$+$ie(B 1.8.6
e$B$^$G$N5sF0$H$"$C$F$$$^$;$s!#e(B

% ruby-1.8.6 -ve ‘p(/(.)(.)(\d+)(\d)/.match(“THX1138: The
Movie”).select(0, 2, -2))’
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
-e:1:in `select’: wrong number of arguments (3 for 0) (ArgumentError)
from -e:1

% ruby-1.8.6 -ve ‘p(/(.)(.)(\d+)(\d)/.match(“THX1138: The Movie”).select
{ true })’
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
[“HX1138”, “H”, “X”, “113”, “8”]

[email protected]@$,$D$$$?$N$Oe(B 1.8.2 e$B$G$9$,!"$=$NCJ3,$G<B:][email protected]@$Ke(B
e$B?)$$0c$$$,$"$j$^$9!#e(B

[email protected]@$O$^$D$b$H$5$s$N$$$&$h$&$Ke(B values_at e$B$G$9$,!"<BAu$Oe(B
Enumerable e$BE*$J$b$N$G$9!#e(B

e$B$=$7$F!"e(B1.8.0 e$B$Oe(B values_at e$B$He(B Enumerable
e$BE*$J$b$N$,:.$6$C$Fe(B
e$B$$$F!"e(Bvalues_at e$B$N$[$&$Oe(B values_at
e$B<+BN$r;H$($H$$$&7Y9p$,=Pe(B
e$B$^$9!#e(B

% ruby-1.8.0 -ve ‘p(/(.)(.)(\d+)(\d)/.match(“THX1138: The
Movie”).select(0, 2, -2))’
ruby 1.8.0 (2003-08-04) [i686-linux]
-e:1: warning: MatchData#select(index…) is deprecated; use
MatchData#values_at
[“HX1138”, “X”, “113”]

% ruby-1.8.0 -ve ‘p(/(.)(.)(\d+)(\d)/.match(“THX1138: The Movie”).select
{ true })’
ruby 1.8.0 (2003-08-04) [i686-linux]
[“HX1138”, “H”, “X”, “113”, “8”]

e$B$3$l$r$_$k$H!"$`$7$me(B rdoc
[email protected]@$,4V0c$C$F$$$F!"$=$N4V0c$Ce(B
e$B$?@bL@$Ke(B 1.9 e$B$,=>$C$F$7$^$C$?$H;W$($k$N$G$9$,$I$&$G$7$g$&$+e(B?

(e$B$=$7$F!"e(B1.8.7 e$B$K$=$l$,e(B backport
[email protected]$,H/@8$7$F$*e(B
e$B$j!"e(Brubyspec e$B$G8!=P$5$l$k$N$G$9$,!#e(B)

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34562] Re: /(.)(.)/.match(“ab”).select {|v|
true } is empty”
on Thu, 1 May 2008 21:54:15 +0900, Tanaka A. [email protected]
writes:

|> MatchData#selecte$B$Oe(Bvalues_ate$B$Ne(Baliase$B$G$9$+$ie(BEnumerablee$B7O$Ne(B
|> selecte$B$H$O5sF0$,0[$J$j$^$9!#La$jCM$O;XDj$7$?0z?t$r%$%s%G%C%/e(B
|> e$B%9$H$9$kCM$rMWAG$H$9$kG[Ns$G$9!#e(BRDoce$B$K$O0J2<$N$h$&$K$"$j$^$9!#e(B
|
|e$B$*$)!“e(Brdoc e$B$OFI$s$G$^$;$s$G$7$?!#e(B
|
|e$B$7$+$7!”[email protected]@$Oe(B 1.8.1 e$B$+$ie(B 1.8.6 e$B$^$G$N5sF0$H$"$C$F$$$^$;$s!#e(B
|
|% ruby-1.8.6 -ve ‘p(/(.)(.)(\d+)(\d)/.match(“THX1138: The Movie”).select(0, 2, -2))’
|ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
|-e:1:in `select’: wrong number of arguments (3 for 0) (ArgumentError)
| from -e:1
|
|% ruby-1.8.6 -ve ‘p(/(.)(.)(\d+)(\d)/.match(“THX1138: The Movie”).select { true })’
|ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
|[“HX1138”, “H”, “X”, “113”, “8”]

1.8e$B$G$Oe(BMatchData#selecte$B$O!"%V%m%C%/$,M?$($i$l$?$ie(BEnumerablee$B7O!“e(B
e$B0z?t$,M?$($i$l$?$ie(Bvalues_ate$B$H$$$&F0$-$r$7$F$$$^$7$?!#$,!”:.$8e(B
e$B$k$N$ONI$/[email protected]$m$&$H;W$C$?3P$($O$"$j$^$9!#e(B

e$B$G!"e(BMatchDatae$B$Oe(BEnumerablee$B$re(Bincludee$B$7$F$$$J$$$7!"e([email protected]$1e(B
Enumerablee$B7O$NF0$-$r$7$F$b$7$g$&$,[email protected]$m$&$H;W$C$Fe(B1.9e$B$r8=e(B
e$B:$N$h$&$K$7$?$h$&$J5$$,$7$^$9$,!"e(B1.8e$B$G$OJ,N%$9$kJ}8~$K?J2=e(B
e$B$7$F$?$
$?$$$G$9$M$’!#F1$8?M$,:n6H$7$?$H$O;W$($J$$;YN%LGNv$5!#e(B
e$BH?>J$G$9!#e(B

|e$B$3$l$r$_$k$H!"$`$7$me(B rdoc [email protected]@$,4V0c$C$F$$$F!"$=$N4V0c$Ce(B
|e$B$?@bL@$Ke(B 1.9 e$B$,=>$C$F$7$^$C$?$H;W$($k$N$G$9$,$I$&$G$7$g$&$+e(B?

e$B$H$$$&$+!"e(B1.8e$B$He(B1.9e$B$H$G0c$&;[email protected]$G0[$J$kH=CG$r$7$F$7$^$C$?$H$$e(B
e$B$&$3$H$N$h$&$G$9!#$4$a$s$J$5$$!#e(B

|(e$B$=$7$F!"e(B1.8.7 e$B$K$=$l$,e(B backport [email protected]$,H/@8$7$F$*e(B
|e$B$j!"e(Brubyspec e$B$G8!=P$5$l$k$N$G$9$,!#e(B)

[email protected]$rH/@8$5$;$k$N$OK\0U$G$O$J$$$N$G!“e(B
e$B$$$^$5$i$G$9$,e(B1.8.7e$B$Ne(BMatchData#selecte$B$Oe(B1.8.6e$B$HF1$8$h$&$Ke(B
Enumerablee$B7O$NF0:n$KLa$9e(B(RDoce$B$b$=$l$K$”$o$;$F=q$-49$($ke(B)e$B$Y$-e(B
e$B$G$7$g$&!#e(B

e$B$G!“e(B1.9e$B$G$I$&$9$k$+$G$9$,!“e(BMatchDatae$B$KBP$7$Fe(BEnumerablee$B7O$Ne(B
select([email protected]$1e(B)e$B$,I,MW$K$J$k6ILL$O$[$H$s$I$J$$$H;W$$$^$9$7!”$H$Oe(B
e$B$$$(e(Bselecte$B$H$$$&%a%=%C%I$r8+$k$HC/$b$,e(BEnumerablee$B7O$NF0:n$r4|e(B
e$BBT$7$^$9$+$i!”$$$C$=:o=|$7$F$7$^$&$N$,$h$$$N$G$O$J$$$+$H;W$$e(B
e$B$^$9!#e(B

e$B$I$&$G$7$g$&!)e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

In article [email protected],
Yukihiro M. [email protected] writes:

1.8e$B$G$Oe(BMatchData#selecte$B$O!"%V%m%C%/$,M?$($i$l$?$ie(BEnumerablee$B7O!"e(B
e$B0z?t$,M?$($i$l$?$ie(Bvalues_ate$B$H$$$&F0$-$r$7$F$$$^$7$?!#e(B

e$B$=$&$$$&F0$-$r$7$F$$$?$N$Oe(B 1.8.0 [email protected]$1$G$9!#e(B

e$B$,!":.$8e(B
e$B$k$N$ONI$/[email protected]$m$&$H;W$C$?3P$($O$"$j$^$9!#e(B

e$B$=$N;W$$$Oe(B 1.8.1 e$B$G<B8=$5$l!"$=$l0J9_$O0z?t$,M?$($i$l$k$H%(e(B
e$B%i!<$K$J$C$F$$$^$9!#e(B

[email protected]$rH/@8$5$;$k$N$OK\0U$G$O$J$$$N$G!“e(B
e$B$$$^$5$i$G$9$,e(B1.8.7e$B$Ne(BMatchData#selecte$B$Oe(B1.8.6e$B$HF1$8$h$&$Ke(B
Enumerablee$B7O$NF0:n$KLa$9e(B(RDoce$B$b$=$l$K$”$o$;$F=q$-49$($ke(B)e$B$Y$-e(B
e$B$G$7$g$&!#e(B

e$B$=$&;W$$$^$9!#e(B

e$B$G!“e(B1.9e$B$G$I$&$9$k$+$G$9$,!“e(BMatchDatae$B$KBP$7$Fe(BEnumerablee$B7O$Ne(B
select([email protected]$1e(B)e$B$,I,MW$K$J$k6ILL$O$[$H$s$I$J$$$H;W$$$^$9$7!”$H$Oe(B
e$B$$$(e(Bselecte$B$H$$$&%a%=%C%I$r8+$k$HC/$b$,e(BEnumerablee$B7O$NF0:n$r4|e(B
e$BBT$7$^$9$+$i!”$$$C$=:o=|$7$F$7$^$&$N$,$h$$$N$G$O$J$$$+$H;W$$e(B
e$B$^$9!#e(B

e$B$I$&$G$7$g$&!)e(B

[ruby-dev:15419] e$B$r8+$D$1$FFI$$^$7$?$,!"M$7$+$C$?$N$O7k6Ie(B
select e$B$8$c$J$/$Fe(B values_at
[email protected]$C$?!"$C$F$$$&$3$H$J$s$G$9$+$M!#e(B

e$B:o=|$9$k$H$$$&$N$O!"e(BMatchData#select e$B$N:G=i$N0U?^$K1h$C$F$$e(B
e$B$k$H$O$$$($k$s$8$c$J$$$G$7$g$&$+!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs