Title: RE: need help

Works great, thanks.

Mike

-----Original Message-----
From: Eric Heaton [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 19, 2000 10:27 AM
To: Nolen, Mike
Subject: Re: need help


a couple of things:
1. the regular expression is doing ".*" greedy matching (see p. 63 of the
Camel book, 2nd ed., or the perlre manpage), so it will match as much as it
can up to a '<', which is why it's only returning the last item. try a
non-greedy match, ".*?".
2. the code is destructively modifying $aa (using substitution/replace), so
it will always only find one item. you might want to try a simple match with
the /g modifier:

$aa = "Mike <mike\@mike.com>, Mark <mark\@mark.com>";
while( $aa =~ m/\<(.*?)\>/g ) {
    print "$1\n";
}

this assumes that '<' or '>' may not appear between enclosing '<' and '>'
characters.

hope this helps
    -----Original Message-----
    From: Nolen, Mike <[EMAIL PROTECTED]>
    To: Perl-Win32-Users Mailing List
<[EMAIL PROTECTED]>
    Date: Friday, May 19, 2000 11:54 AM
    Subject: need help


    I need to return all data inside each set of <> in a string ...
    I've included 2 examples, but they both return the last item only...
    TIA, mike
    -----------------------------
    $aa = "Mike <mike\@mike.com>, Mark <mark\@mark.com>";
    print "$aa\n";
    -- ie. 1
    $aa =~ s/^.*\<(.*)\>.*$/\1/g;
    print "$aa\n";

    --ie. 2
    for ( $aa =~ s/^.*\<(.*)\>.*$/\1/g )

            print "$aa\n";
    }



Reply via email to