[tpm] Regex question

Uri Guttman uri at stemsystems.com
Tue Jul 8 18:13:03 PDT 2008


>>>>> "MS" == Mike Stok <mike at stok.ca> writes:

  MS> Maybe I misunderstood the question...  You can say

  MS>    my ($bar) = $foo =~ /(\w+-\d+)-\d+/;

  MS> which will assing $1 to $bar if the match succeeds.

and it will assign undef if it fails. and since the grabbed string will
always be true (it can't be '' or '0') you can test $bar to see if the
match succeeded.

uri

-- 
Uri Guttman  ------  uri at stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


More information about the toronto-pm mailing list