--- Families Laws <[EMAIL PROTECTED]> wrote:
> I have a input string of ..{....}..{..}...,
> I need to get the output in an array that contains
> only: {....}  {..}  character strings.
> 
> I tried:
> 
> $instr1 = "111{first first}222 333{second}444";
> $_ = $instr1;      
> @outstr = m/{.+}/g;
> 
> @outstr has a value of {first first}222 333{second};
> 
> I would like the output to be:
>  $outstr[0] = first first 
>  $outsrt[1] = second
> 
> Can anybody help?  Thanks in advance. 

    use strict;
    my $instr1 = "111{first first}222 333{second}444";
    my @outstr = ( $instr1 =~ m/{([^}]+)}/g );

Basically, you need to use parentheses in the regular expression to capture the data 
and then put
parens around the entire expression to put in list context.

If you prefer a syntax closer to what you had, you can do the following:

    my $instr1 = "111{first first}222 333{second}444";
    $_ = $instr1;
    my @outstr = m/{([^}]+)}/g;

Also, I stripped out your dot star and replaced it with a negated character class.  See
http://www.perlmonks.org/index.pl?node_id=24640 for why this is done.

Cheers,
Curtis "Ovid" Poe

=====
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to