[Wellington-pm] capturing quantified matches

Richard Hector richard at walnut.gen.nz
Tue Oct 4 01:45:22 PDT 2011


Hi all,

I'm trying to use a regex like this:

($foo, $bar, @baz) = /^(xx)\s(yy)\s(zz)*$/

but it seems I can't get all the arbitrary number of values from the 3rd
capture. Any suggestions for that?

I guess I could do it in two steps, something like this:

s/^(xx)\s(yy)\s// && ($foo, $bar) = ($1, $2);
@baz = /^(zz)/g;

.. since /g seems to return multiple matches where ()* doesn't.

Any other ideas?

That's untested code, much simpler than the real thing, but I think the
principles I'm after are clear enough ..

Thanks,

Richard




More information about the Wellington-pm mailing list