Perhaps something like

my $string = '/blabla/dir/nextdir/name.txt';

$string =~ /(.+)([^\/]*)$/;
my $everythinguptoandincludingthelastslash = $1;
my $everythingbeyondthelastslashtotheendoftheline = $2;
# [^\/] == notaslash (escaped by a backslash)
# [...]* == zero or more of them
# $/ == endofline

- Roger -


----- Original Message ----- 
From: "Bruno Veldeman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 09, 2001 9:07 PM
Subject: Regex question


> Hi,
>  
> I can't seem to get the regex right for this:
>  
> I have a string with this format "/blabla/dir/nextdir/name.txt"
> I want only 'name.txt' in one string and the rest in another string.
>  
> It would be nice explaining the regex in plain english.
>  
> Or better, how do I learn to use regex?
>  
> For now it's like chineese to me.
> (And I don't know chineese ;-) )
>  
> Thanks.
> 
> 
> 
> 

Reply via email to