RegEx: odd number of slashes? and too many slashes?

D

Dan Wilkin

Why does the following code work to find the literal UNC path specified.
altPath should have worked, right? It looks like the regex engine is
gobbling up slashes!! Perl 5.x


#my $altPath = '\\\\websrv\\VMServer\\cvs\\SAMS\\archives';
my $rootPath = '\\\\\\\websrv\\\VMServer\\\cvs\\\SAMS\\\archives';

# load the list of obsolete files
sub loadObsoletes {
my $i = 0;
my $line;
open SRC, $src_name or die "Can't open file '$src_name'";
while (<SRC>) {
chomp;
/$rootPath(.+?)-arc - (.+)/o; # extract the filenames
into an array
print "Matched: <$`> $& <$'>\n";
print "Parsed line $i as: {$1}{$2}\n" if $verbose;
$line = $1;
$line =~ s[\\][/]g;
print "Subst as: {$line}\n" if $verbose;
$LoF[$i] = $line;
$i++;
}
close SRC;
print "Listed source file as: @LoF" if $verbose;
}


Thnx,
Dan
 
R

robic0

Why does the following code work to find the literal UNC path specified.
altPath should have worked, right? It looks like the regex engine is
gobbling up slashes!! Perl 5.x


#my $altPath = '\\\\websrv\\VMServer\\cvs\\SAMS\\archives';
my $rootPath = '\\\\\\\websrv\\\VMServer\\\cvs\\\SAMS\\\archives';

# load the list of obsolete files
sub loadObsoletes {
my $i = 0;
my $line;
open SRC, $src_name or die "Can't open file '$src_name'";
while (<SRC>) {
chomp;
/$rootPath(.+?)-arc - (.+)/o; # extract the filenames
into an array
print "Matched: <$`> $& <$'>\n";
print "Parsed line $i as: {$1}{$2}\n" if $verbose;
$line = $1;
$line =~ s[\\][/]g;
print "Subst as: {$line}\n" if $verbose;
$LoF[$i] = $line;
$i++;
}
close SRC;
print "Listed source file as: @LoF" if $verbose;
}


Thnx,
Dan

U tell me. If you don't understand "in solution" then you can't post here

robic0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top