Dirk Bremer wrote:

> Anthony,
>  
> I tried your regex example out of curiosity:
>  
> my $str = 'C:\Program
> Files\Oracle\Inventory\Components21\oracle.swd.jre\1.1.8.16.0\resources\
> CompID.properties';
> $str =~ /\\([\w\._-\s]+)$/g;
> print(">$1<\n"); 
> 
> While it does produce the correct result in this instance, it also
> produces a warning:

You need to put the '-' as the first or last item else it tries to act like
a character class separator.

$str =~ /\\([\w\._\s-]+)$/g;    # moved - to end

My preference for getting the basename (barring using the module) is :

my $path = "c:\\temp\\foo.pl";
(my $basename = $path) =~ s/^.*[\\\/]//;        # works on UNIX paths also

> c:\temp>regex
> False [] range "_-\s" before HERE mark in regex m/\\([\w\._-\s << HERE
> ]+)$/ at C:\Perl\Scripts\regex.pl line 7.
> 
>>CompID.properties<
> 


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to