Mike Lesser wrote:
> Hi all. I have this strange relationship with Regex. I seem to be able
> to get simple
> stuff accomplished, but in really brute-force ways, and I think I'm
> missing some
> fundamental aspect of its usage. I'm forced to chomp thru strings from
> the
> side like pac-man. It's like I can do a simple match or substitution,
> but I can't
> get stuff out of a string that I want (which is what seems to be going
> on in all
> the examples).
> 
> For example, if I have a string that goes like
> 
>    "Joe Shmoe (alphanumerics)"
        Are you after the 'alphanumerics' and replacing or selecting.

        Something like:
        my $MyAlpha = '';
        if ( /^.+\(([^)])+\)/ ) {
                $MyAlpha = $1;
       }
        So this would have alphanumerics in $MyAlpha.
        ^               Start of field
        .+              1 or more characters
        \(              find a left paren
        ([^)]+) Now gobble up to but not including the next )
                        $1 will hold what is between the Parens
        \)              find a right paren

        A good place to start is a book by Friedl ( Mastering Regular 
Expressions ) ISBN: 0596002890

Wags ;) 
> 
> and I want to get the alphanumerics between the parens, It's like
> pulling teeth,
> I think (i think..) what I want to do is match the stuff that's _not_
> between the
> parens, and substitute that to nothing? Is that how to do it?
> 
> Mike



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to