SPUG: regular expression difficulty, plus compiled perl

Tim Rosmus trosmus at nwnexus.net
Tue Mar 28 12:13:45 CST 2000


|#  But I'm still interested to know how I would parse the same info out of a
|#  variable containing "c:\dir1\subdir1\subdir2\my.exe", basically how to trim
|#  the filename off the end.
|#  
|#  About the other solutions...
|#  
|#  SOLUTION 1:
|#  =================================
|#  $test1 =~ s#.*\\##;    # replace everything
|#                         # before the last \
|#                         # with nothing...
|#  =================================
|#  This is the exact opposite of what I wanted to do, if you test the code it
|#  actually ends up with $test1 = "";
|#  

How about...

$test1 =~ s#(.*)\\.*?$##;

$1 should contain the path leading up to filename.
-- 
                Tim Rosmus <trosmus at nwnexus.net>
                   Postmaster / USENET / DNS
                    WinStar Northwest Nexus



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace "action" below by subscribe or unsubscribe
           Email to majordomo at pm.org: "action" spug-list your_address





More information about the spug-list mailing list