Home: Perl Programming Help: Regular Expressions:
Why isnt my regex matching anything?



guru_perl
Novice

Dec 19, 2010, 1:40 AM


Views: 5022
Why isnt my regex matching anything?

 
For the input line shown below,the regex is not matching,I couldnt find anything wrong?Need your input perl gurus

Code
INPUT LINE:.\\directory\programfiles\documents\data\lookup\file.c;//programfiles/documents/data/lookup/file.c - LABEL : 5 
if (my ($key, $value) = $line =~ /\.\\(.+?)-\d+;.+?;(.+?)\s-\s/) {
}

OUTPUT:-
KEY:\\directory\programfiles\documents\data\lookup\file.c
VALUE://programfiles/documents/data/lookup/file.c


(This post was edited by guru_perl on Dec 19, 2010, 2:16 AM)


JasperD
Novice

Dec 19, 2010, 5:36 AM


Views: 5016
Re: [guru_perl] Why isnt my regex matching anything?

Not sure what you want here.

Code
\.\\(.+?)-

Matches all the way up to '-' before 'LABEL'.
Then you are asking to match digits.

Try starting with:

Code
/\.(\\.+?);(\/\/.+?)-/


That will at least give you the value and key you want.