From: "冷雨" Date: 2010-10-17T12:56:28+09:00 Subject: Re: Can't understand String#split's behavior --0015174c123ef9836a0492c80422 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sorry for my careless. And thank you very match. On Sun, Oct 17, 2010 at 10:42 AM, botp wrote: > On Sun, Oct 17, 2010 at 8:46 AM, =E5=86=B7=E9=9B=A8 = wrote: > > I think that /A/ and /(A)/ are almost equivalent, > > almost > > > but why can't I use /(A)/ to split string? > > as documented, you can, but w a different behaviour/result for split > > > (from ruby core) > =3D=3D=3D Implementation from String > > -------------------------------------------------------------------------= ----- > str.split(pattern=3D$;, [limit]) -> anArray > > > -------------------------------------------------------------------------= ----- > > Divides str into substrings based on a delimiter, returning an array of > these substrings. > > If pattern is a String, then its contents are used as the > delimiter when splitting str. If pattern is a single > space, str is split on whitespace, with leading whitespace and runs of > contiguous whitespace characters ignored. > > If pattern is a Regexp, str is divided where the pattern > matches. Whenever the pattern matches a zero-length string, str is split > into individual characters. If pattern contains groups, the > respective matches will be returned in the array as well. > .... > > --0015174c123ef9836a0492c80422--