From: Mike Dillinger <[EMAIL PROTECTED]>
> --- Original Message
> From: Zysman, Roiy <[EMAIL PROTECTED]>
> 
> ZR> Is there a way to extract a filename out of a path string using
> just one ZR> RegEx and not using the split function ?
> 
> ZR> For Example, I want to extract foo.txt from /my/long/path/foo.txt
> path ZR> string.
> 
> I found this cool trick a while ago and it works nicely.
> 
> my($directory, $filename) = $text =~ m/(.*\/)(.*)$/;
> print "D=$directory, F=$filename\n";

It does? Let me try:

        my xt = 'c:\soft\wscite\scite.exe';
        my($directory, $filename) = $text =~ m/(.*\/)(.*)$/;
        print "D=$directory, F=$filename\n";

>>  D=, F=

The delimiter depends on the OS, Unixes use /, Windows use \ (but 
accepts / on most places as well), Macintoshes (at least the old 
ones) use :. And then there is VMS.

If you want to be portable use a module.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to