String.scan is better for my purpose. because I need to group the
sub-matches by using join. Thanks anyway.
Shannon
On Sat, 7 Dec 2002 07:18:29 +0900
Mauricio Fern~{an~}dez <batsman.geo / yahoo.com> wrote:
> On Sat, Dec 07, 2002 at 06:26:39AM +0900, Shannon Fang wrote:
> > Please help me with the following problem:
> >
> > / ( ( a ) ( b ) ) (c)/
> > 1 2 3 4
> >
> > in Match Data, it seems that $1.. $4 are defined as above. How can I let
> > regex.match(string) method to return an array like this:
> >
> > [ [a,b], c] ?
>
> Perhaps I'm being stupid here, but what's wrong about
>
> irb(main):003:0> "abc" =~~ /(?:(a)(b))(c)/
> 0
> irb(main):004:0> p [[$1,$2],$3]
> [["a", "b"], "c"]
> nil
>
> ?
>
> --
> _ _
> | |__ __ _| |_ ___ _ __ ___ __ _ _ __
> | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \
> | |_) | (_| | |_\__ \ | | | | | (_| | | | |
> |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
> Running Debian GNU/Linux Sid (unstable)
> batsman dot geo at yahoo dot com
>
> Ok, I'm just uploading the new version of the kernel, v1.3.33, also
> known as "the buggiest kernel ever".
> -- Linus Torvalds