Home: Perl Programming Help: Regular Expressions:
Regex failing



iphone
User

Feb 3, 2011, 1:42 AM


Views: 4577
Regex failing

Why is the below regex failing for the below input ?

\amss\products\76xx\wconnect\bthost\brew\statext\src\aeebtextag.c-36572;M76XXDFDCENJAD3555474RPLF.flf;//source/wconnect/bthost/brew/statext/rel/00.00.26/src/AEEBTExtAG.c - LABEL : 1

OUTPUT:-AEEBTExtAG.c(just the file name)


Code
(my $file_name) = $line =~ /;\/[^\/](.*)\s-\s/;



BillKSmith
Veteran

Feb 3, 2011, 12:42 PM


Views: 4564
Re: [iphone] Regex failing

Your sample data does not have the semicolon or the whitespace that your RE requires. Use:


Code
    (my $file_name) = $line =~ /\/([^\/]+)-/;

Good Luck,
Bill