When debugging regular expressions (and the text they should match against), I find a good technique to chop off elements from the regex until it matches:
my $line = 'amss\products\76xx\wconnect\bthost\brew\statext\src\aeebte +xtag.c-36572;FILE.flf;//source/wconnect/bthost/brew/statext/rel/00.00 +.26/src/AEEBTExtAG.c - LABEL : 1'; print "Has ;/" if ($line =~ /;\//); print "Has ;\/[^\/]" if ($line =~ /;\/[^\/]/); print "Has ;\/[^\/](.*)\s-\s" if ($line =~ /;\/[^\/](.*)\s-\s/); (my $file_name) = $line =~ /;\/[^\/](.*)\s-\s/; print $file_name;
That way you can easily see in your program where the matching stops. You could also use re 'debug', or output messages when the regular expression engine backtracks, but I found it always easier to manually create the relevant steps to output where my match progresses.
In reply to Re: Regex failing
by Corion
in thread Regex failing
by iphone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |